Files

80 lines
2.7 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace FictionArchive.Service.NovelService.Migrations
{
/// <inheritdoc />
public partial class AddImages : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "CoverImageId",
table: "Novels",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "Images",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
OriginalPath = table.Column<string>(type: "text", nullable: false),
NewPath = table.Column<string>(type: "text", nullable: true),
ChapterId = 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_Images", x => x.Id);
table.ForeignKey(
name: "FK_Images_Chapter_ChapterId",
column: x => x.ChapterId,
principalTable: "Chapter",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Novels_CoverImageId",
table: "Novels",
column: "CoverImageId");
migrationBuilder.CreateIndex(
name: "IX_Images_ChapterId",
table: "Images",
column: "ChapterId");
migrationBuilder.AddForeignKey(
name: "FK_Novels_Images_CoverImageId",
table: "Novels",
column: "CoverImageId",
principalTable: "Images",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Novels_Images_CoverImageId",
table: "Novels");
migrationBuilder.DropTable(
name: "Images");
migrationBuilder.DropIndex(
name: "IX_Novels_CoverImageId",
table: "Novels");
migrationBuilder.DropColumn(
name: "CoverImageId",
table: "Novels");
}
}
}