using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace FictionArchive.Service.NovelService.Migrations
{
///
public partial class Initial : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "LocalizationKey",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LocalizationKey", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Person",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: false),
ExternalUrl = table.Column(type: "text", nullable: true),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Person", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sources",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "text", nullable: false),
Key = table.Column(type: "text", nullable: false),
Url = table.Column(type: "text", nullable: false),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sources", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TranslationEngines",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Key = table.Column(type: "text", nullable: false),
DisplayName = table.Column(type: "text", nullable: false),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TranslationEngines", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Novels",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AuthorId = table.Column(type: "bigint", nullable: false),
Url = table.Column(type: "text", nullable: false),
RawLanguage = table.Column(type: "integer", nullable: false),
RawStatus = table.Column(type: "integer", nullable: false),
StatusOverride = table.Column(type: "integer", nullable: true),
SourceId = table.Column(type: "bigint", nullable: false),
ExternalId = table.Column(type: "text", nullable: false),
NameId = table.Column(type: "bigint", nullable: false),
DescriptionId = table.Column(type: "bigint", nullable: false),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Novels", x => x.Id);
table.ForeignKey(
name: "FK_Novels_LocalizationKey_DescriptionId",
column: x => x.DescriptionId,
principalTable: "LocalizationKey",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Novels_LocalizationKey_NameId",
column: x => x.NameId,
principalTable: "LocalizationKey",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Novels_Person_AuthorId",
column: x => x.AuthorId,
principalTable: "Person",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Novels_Sources_SourceId",
column: x => x.SourceId,
principalTable: "Sources",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Tags",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Key = table.Column(type: "text", nullable: false),
DisplayNameId = table.Column(type: "bigint", nullable: false),
TagType = table.Column(type: "integer", nullable: false),
SourceId = table.Column(type: "bigint", nullable: true),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tags", x => x.Id);
table.ForeignKey(
name: "FK_Tags_LocalizationKey_DisplayNameId",
column: x => x.DisplayNameId,
principalTable: "LocalizationKey",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Tags_Sources_SourceId",
column: x => x.SourceId,
principalTable: "Sources",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "LocalizationText",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Language = table.Column(type: "integer", nullable: false),
Text = table.Column(type: "text", nullable: false),
TranslationEngineId = table.Column(type: "bigint", nullable: true),
LocalizationKeyId = table.Column(type: "bigint", nullable: true),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LocalizationText", x => x.Id);
table.ForeignKey(
name: "FK_LocalizationText_LocalizationKey_LocalizationKeyId",
column: x => x.LocalizationKeyId,
principalTable: "LocalizationKey",
principalColumn: "Id");
table.ForeignKey(
name: "FK_LocalizationText_TranslationEngines_TranslationEngineId",
column: x => x.TranslationEngineId,
principalTable: "TranslationEngines",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Chapter",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Revision = table.Column(type: "bigint", nullable: false),
Order = table.Column(type: "bigint", nullable: false),
Url = table.Column(type: "text", nullable: true),
NameId = table.Column(type: "bigint", nullable: false),
BodyId = table.Column(type: "bigint", nullable: false),
NovelId = table.Column(type: "bigint", nullable: true),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Chapter", x => x.Id);
table.ForeignKey(
name: "FK_Chapter_LocalizationKey_BodyId",
column: x => x.BodyId,
principalTable: "LocalizationKey",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Chapter_LocalizationKey_NameId",
column: x => x.NameId,
principalTable: "LocalizationKey",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Chapter_Novels_NovelId",
column: x => x.NovelId,
principalTable: "Novels",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "NovelNovelTag",
columns: table => new
{
NovelsId = table.Column(type: "bigint", nullable: false),
TagsId = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NovelNovelTag", x => new { x.NovelsId, x.TagsId });
table.ForeignKey(
name: "FK_NovelNovelTag_Novels_NovelsId",
column: x => x.NovelsId,
principalTable: "Novels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_NovelNovelTag_Tags_TagsId",
column: x => x.TagsId,
principalTable: "Tags",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Chapter_BodyId",
table: "Chapter",
column: "BodyId");
migrationBuilder.CreateIndex(
name: "IX_Chapter_NameId",
table: "Chapter",
column: "NameId");
migrationBuilder.CreateIndex(
name: "IX_Chapter_NovelId",
table: "Chapter",
column: "NovelId");
migrationBuilder.CreateIndex(
name: "IX_LocalizationText_LocalizationKeyId",
table: "LocalizationText",
column: "LocalizationKeyId");
migrationBuilder.CreateIndex(
name: "IX_LocalizationText_TranslationEngineId",
table: "LocalizationText",
column: "TranslationEngineId");
migrationBuilder.CreateIndex(
name: "IX_NovelNovelTag_TagsId",
table: "NovelNovelTag",
column: "TagsId");
migrationBuilder.CreateIndex(
name: "IX_Novels_AuthorId",
table: "Novels",
column: "AuthorId");
migrationBuilder.CreateIndex(
name: "IX_Novels_DescriptionId",
table: "Novels",
column: "DescriptionId");
migrationBuilder.CreateIndex(
name: "IX_Novels_NameId",
table: "Novels",
column: "NameId");
migrationBuilder.CreateIndex(
name: "IX_Novels_SourceId",
table: "Novels",
column: "SourceId");
migrationBuilder.CreateIndex(
name: "IX_Tags_DisplayNameId",
table: "Tags",
column: "DisplayNameId");
migrationBuilder.CreateIndex(
name: "IX_Tags_SourceId",
table: "Tags",
column: "SourceId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Chapter");
migrationBuilder.DropTable(
name: "LocalizationText");
migrationBuilder.DropTable(
name: "NovelNovelTag");
migrationBuilder.DropTable(
name: "TranslationEngines");
migrationBuilder.DropTable(
name: "Novels");
migrationBuilder.DropTable(
name: "Tags");
migrationBuilder.DropTable(
name: "Person");
migrationBuilder.DropTable(
name: "LocalizationKey");
migrationBuilder.DropTable(
name: "Sources");
}
}
}