352 lines
16 KiB
C#
352 lines
16 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Modules.Library.Database.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "AnimeTitles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Completed = table.Column<bool>(type: "boolean", nullable: false),
|
|
ExpirationTime = table.Column<TimeSpan>(type: "interval", nullable: false),
|
|
Deleted = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AnimeTitles", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Genres",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
Deleted = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Genres", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Languages",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CodeIso3 = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: false),
|
|
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
IconId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
Deleted = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Languages", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Anime_Seasons",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Order = table.Column<int>(type: "integer", nullable: false),
|
|
Variant = table.Column<int>(type: "integer", nullable: false),
|
|
Completed = table.Column<bool>(type: "boolean", nullable: false),
|
|
ExpirationTime = table.Column<TimeSpan>(type: "interval", nullable: false),
|
|
Deleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
AnimeTitleId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
Number = table.Column<int>(type: "integer", nullable: true),
|
|
Director = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
|
OriginCountry = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Anime_Seasons", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Anime_Seasons_AnimeTitles_AnimeTitleId",
|
|
column: x => x.AnimeTitleId,
|
|
principalTable: "AnimeTitles",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AnimeItem",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Order = table.Column<int>(type: "integer", nullable: false),
|
|
Variant = table.Column<int>(type: "integer", nullable: false),
|
|
Completed = table.Column<bool>(type: "boolean", nullable: false),
|
|
ExpirationTime = table.Column<TimeSpan>(type: "interval", nullable: false),
|
|
Deleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
AnimeTitleId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AnimeItem", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_AnimeItem_AnimeTitles_AnimeTitleId",
|
|
column: x => x.AnimeTitleId,
|
|
principalTable: "AnimeTitles",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Anime_Episodes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Order = table.Column<int>(type: "integer", nullable: false),
|
|
Variant = table.Column<int>(type: "integer", nullable: false),
|
|
Completed = table.Column<bool>(type: "boolean", nullable: false),
|
|
ExpirationTime = table.Column<TimeSpan>(type: "interval", nullable: false),
|
|
Deleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
AnimeTitleId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
Type = table.Column<string>(type: "text", nullable: false),
|
|
Number = table.Column<int>(type: "integer", nullable: true),
|
|
Duration = table.Column<TimeSpan>(type: "interval", nullable: true),
|
|
AnimeSeasonId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Anime_Episodes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Anime_Episodes_AnimeTitles_AnimeTitleId",
|
|
column: x => x.AnimeTitleId,
|
|
principalTable: "AnimeTitles",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Anime_Episodes_Anime_Seasons_AnimeSeasonId",
|
|
column: x => x.AnimeSeasonId,
|
|
principalTable: "Anime_Seasons",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CommonProperties",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PreviewId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
AnnouncementDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
EstimatedReleaseDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
ReleaseDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
AnimeItemId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
AnimeTitleId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CommonProperties", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CommonProperties_AnimeTitles_AnimeTitleId",
|
|
column: x => x.AnimeTitleId,
|
|
principalTable: "AnimeTitles",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DescriptionItem",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Value = table.Column<string>(type: "text", nullable: false),
|
|
IsOriginal = table.Column<bool>(type: "boolean", nullable: false),
|
|
LanguageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CommonPropertiesId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DescriptionItem", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DescriptionItem_CommonProperties_CommonPropertiesId",
|
|
column: x => x.CommonPropertiesId,
|
|
principalTable: "CommonProperties",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "GenreProportionItem",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Proportion = table.Column<decimal>(type: "numeric", nullable: true),
|
|
GenreId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CommonPropertiesId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_GenreProportionItem", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_GenreProportionItem_CommonProperties_CommonPropertiesId",
|
|
column: x => x.CommonPropertiesId,
|
|
principalTable: "CommonProperties",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "MediaInfos",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Type = table.Column<string>(type: "text", nullable: false),
|
|
Url = table.Column<string>(type: "text", nullable: false),
|
|
ContentType = table.Column<string>(type: "text", nullable: false),
|
|
Deleted = table.Column<bool>(type: "boolean", nullable: false),
|
|
CommonPropertiesId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_MediaInfos", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_MediaInfos_CommonProperties_CommonPropertiesId",
|
|
column: x => x.CommonPropertiesId,
|
|
principalTable: "CommonProperties",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "NameItem",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Value = table.Column<string>(type: "text", nullable: false),
|
|
Type = table.Column<string>(type: "text", nullable: false),
|
|
LanguageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CommonPropertiesId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_NameItem", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_NameItem_CommonProperties_CommonPropertiesId",
|
|
column: x => x.CommonPropertiesId,
|
|
principalTable: "CommonProperties",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Anime_Episodes_AnimeSeasonId",
|
|
table: "Anime_Episodes",
|
|
column: "AnimeSeasonId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Anime_Episodes_AnimeTitleId",
|
|
table: "Anime_Episodes",
|
|
column: "AnimeTitleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Anime_Seasons_AnimeTitleId",
|
|
table: "Anime_Seasons",
|
|
column: "AnimeTitleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AnimeItem_AnimeTitleId",
|
|
table: "AnimeItem",
|
|
column: "AnimeTitleId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CommonProperties_AnimeItemId",
|
|
table: "CommonProperties",
|
|
column: "AnimeItemId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CommonProperties_AnimeTitleId",
|
|
table: "CommonProperties",
|
|
column: "AnimeTitleId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CommonProperties_PreviewId",
|
|
table: "CommonProperties",
|
|
column: "PreviewId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DescriptionItem_CommonPropertiesId",
|
|
table: "DescriptionItem",
|
|
column: "CommonPropertiesId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GenreProportionItem_CommonPropertiesId",
|
|
table: "GenreProportionItem",
|
|
column: "CommonPropertiesId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MediaInfos_CommonPropertiesId",
|
|
table: "MediaInfos",
|
|
column: "CommonPropertiesId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_NameItem_CommonPropertiesId",
|
|
table: "NameItem",
|
|
column: "CommonPropertiesId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_CommonProperties_MediaInfos_PreviewId",
|
|
table: "CommonProperties",
|
|
column: "PreviewId",
|
|
principalTable: "MediaInfos",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_CommonProperties_AnimeTitles_AnimeTitleId",
|
|
table: "CommonProperties");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_CommonProperties_MediaInfos_PreviewId",
|
|
table: "CommonProperties");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Anime_Episodes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AnimeItem");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DescriptionItem");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "GenreProportionItem");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Genres");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Languages");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "NameItem");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Anime_Seasons");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AnimeTitles");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "MediaInfos");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "CommonProperties");
|
|
}
|
|
}
|
|
}
|