386 lines
18 KiB
C#
386 lines
18 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using NodaTime;
|
|
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: "LocalizationKeys",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LocalizationKeys", 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),
|
|
Key = table.Column<string>(type: "text", nullable: false),
|
|
Url = table.Column<string>(type: "text", nullable: false),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(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),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_TranslationEngines", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Person",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
NameId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ExternalUrl = table.Column<string>(type: "text", nullable: true),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Person", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Person_LocalizationKeys_NameId",
|
|
column: x => x.NameId,
|
|
principalTable: "LocalizationKeys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
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<Guid>(type: "uuid", nullable: false),
|
|
TagType = table.Column<int>(type: "integer", nullable: false),
|
|
SourceId = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tags", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Tags_LocalizationKeys_DisplayNameId",
|
|
column: x => x.DisplayNameId,
|
|
principalTable: "LocalizationKeys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Tags_Sources_SourceId",
|
|
column: x => x.SourceId,
|
|
principalTable: "Sources",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LocalizationRequests",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
KeyRequestedForTranslationId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
TranslateTo = table.Column<int>(type: "integer", nullable: false),
|
|
EngineId = table.Column<long>(type: "bigint", nullable: false),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LocalizationRequests", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LocalizationRequests_LocalizationKeys_KeyRequestedForTransl~",
|
|
column: x => x.KeyRequestedForTranslationId,
|
|
principalTable: "LocalizationKeys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_LocalizationRequests_TranslationEngines_EngineId",
|
|
column: x => x.EngineId,
|
|
principalTable: "TranslationEngines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LocalizationText",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
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<Guid>(type: "uuid", nullable: true),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LocalizationText", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LocalizationText_LocalizationKeys_LocalizationKeyId",
|
|
column: x => x.LocalizationKeyId,
|
|
principalTable: "LocalizationKeys",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_LocalizationText_TranslationEngines_TranslationEngineId",
|
|
column: x => x.TranslationEngineId,
|
|
principalTable: "TranslationEngines",
|
|
principalColumn: "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<Guid>(type: "uuid", nullable: false),
|
|
DescriptionId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Novels", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Novels_LocalizationKeys_DescriptionId",
|
|
column: x => x.DescriptionId,
|
|
principalTable: "LocalizationKeys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Novels_LocalizationKeys_NameId",
|
|
column: x => x.NameId,
|
|
principalTable: "LocalizationKeys",
|
|
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: "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<Guid>(type: "uuid", nullable: false),
|
|
BodyId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
NovelId = table.Column<long>(type: "bigint", nullable: true),
|
|
CreatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
LastUpdatedTime = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Chapter", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Chapter_LocalizationKeys_BodyId",
|
|
column: x => x.BodyId,
|
|
principalTable: "LocalizationKeys",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Chapter_LocalizationKeys_NameId",
|
|
column: x => x.NameId,
|
|
principalTable: "LocalizationKeys",
|
|
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<long>(type: "bigint", nullable: false),
|
|
TagsId = table.Column<long>(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_LocalizationRequests_EngineId",
|
|
table: "LocalizationRequests",
|
|
column: "EngineId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LocalizationRequests_KeyRequestedForTranslationId",
|
|
table: "LocalizationRequests",
|
|
column: "KeyRequestedForTranslationId");
|
|
|
|
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_Person_NameId",
|
|
table: "Person",
|
|
column: "NameId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tags_DisplayNameId",
|
|
table: "Tags",
|
|
column: "DisplayNameId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tags_SourceId",
|
|
table: "Tags",
|
|
column: "SourceId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Chapter");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LocalizationRequests");
|
|
|
|
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: "Sources");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LocalizationKeys");
|
|
}
|
|
}
|
|
}
|