using System;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace FictionArchive.Service.NovelService.Migrations
{
///
public partial class AddImages : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "CoverImageId",
table: "Novels",
type: "uuid",
nullable: true);
migrationBuilder.CreateTable(
name: "Images",
columns: table => new
{
Id = table.Column(type: "uuid", nullable: false),
OriginalPath = table.Column(type: "text", nullable: false),
NewPath = table.Column(type: "text", nullable: true),
ChapterId = table.Column(type: "bigint", nullable: true),
CreatedTime = table.Column(type: "timestamp with time zone", nullable: false),
LastUpdatedTime = table.Column(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");
}
///
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");
}
}
}