96 lines
3.9 KiB
C#
96 lines
3.9 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using NodaTime;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace FictionArchive.Service.UserNovelDataService.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddNovelVolumeChapter : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Novels",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
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);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Volumes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
NovelId = 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_Volumes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Volumes_Novels_NovelId",
|
|
column: x => x.NovelId,
|
|
principalTable: "Novels",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Chapters",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
VolumeId = 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_Chapters", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Chapters_Volumes_VolumeId",
|
|
column: x => x.VolumeId,
|
|
principalTable: "Volumes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Chapters_VolumeId",
|
|
table: "Chapters",
|
|
column: "VolumeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Volumes_NovelId",
|
|
table: "Volumes",
|
|
column: "NovelId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Chapters");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Volumes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Novels");
|
|
}
|
|
}
|
|
}
|