314 lines
14 KiB
C#
314 lines
14 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace FictionArchive.Service.NovelService.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "LocalizationKey",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
ExternalUrl = table.Column<string>(type: "text", nullable: true),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Url = table.Column<string>(type: "text", nullable: false),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Key = table.Column<string>(type: "text", nullable: false),
|
|
DisplayName = table.Column<string>(type: "text", nullable: false),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
AuthorId = table.Column<long>(type: "bigint", nullable: false),
|
|
Url = table.Column<string>(type: "text", nullable: false),
|
|
RawLanguage = table.Column<int>(type: "integer", nullable: false),
|
|
RawStatus = table.Column<int>(type: "integer", nullable: false),
|
|
StatusOverride = table.Column<int>(type: "integer", nullable: true),
|
|
SourceId = table.Column<long>(type: "bigint", nullable: false),
|
|
ExternalId = table.Column<string>(type: "text", nullable: false),
|
|
NameId = table.Column<long>(type: "bigint", nullable: false),
|
|
DescriptionId = table.Column<long>(type: "bigint", nullable: false),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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: "LocalizationText",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Language = table.Column<int>(type: "integer", nullable: false),
|
|
Text = table.Column<string>(type: "text", nullable: false),
|
|
TranslationEngineId = table.Column<long>(type: "bigint", nullable: true),
|
|
LocalizationKeyId = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Revision = table.Column<long>(type: "bigint", nullable: false),
|
|
Order = table.Column<long>(type: "bigint", nullable: false),
|
|
Url = table.Column<string>(type: "text", nullable: true),
|
|
NameId = table.Column<long>(type: "bigint", nullable: false),
|
|
BodyId = table.Column<long>(type: "bigint", nullable: false),
|
|
NovelId = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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: "Tags",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Key = table.Column<string>(type: "text", nullable: false),
|
|
DisplayNameId = table.Column<long>(type: "bigint", nullable: false),
|
|
TagType = table.Column<int>(type: "integer", nullable: false),
|
|
SourceId = table.Column<long>(type: "bigint", nullable: true),
|
|
NovelId = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedUtc = table.Column<DateTime>(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_Novels_NovelId",
|
|
column: x => x.NovelId,
|
|
principalTable: "Novels",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Tags_Sources_SourceId",
|
|
column: x => x.SourceId,
|
|
principalTable: "Sources",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
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_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_NovelId",
|
|
table: "Tags",
|
|
column: "NovelId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tags_SourceId",
|
|
table: "Tags",
|
|
column: "SourceId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Chapter");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LocalizationText");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Tags");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "TranslationEngines");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Novels");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LocalizationKey");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Person");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Sources");
|
|
}
|
|
}
|
|
}
|