Kavita/API/Data/Migrations/20210128143348_SeriesVolumeChapterChange.cs

112 lines
3.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace API.Data.Migrations
{
public partial class SeriesVolumeChapterChange : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsSpecial",
table: "Volume",
type: "INTEGER",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<int>(
name: "ChapterId",
table: "MangaFile",
type: "INTEGER",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "LastScanned",
table: "FolderPath",
type: "TEXT",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<int>(
name: "ChapterId",
table: "AppUserProgresses",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "Chapter",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Range = table.Column<string>(type: "TEXT", nullable: true),
Number = table.Column<string>(type: "TEXT", nullable: true),
Created = table.Column<DateTime>(type: "TEXT", nullable: false),
LastModified = table.Column<DateTime>(type: "TEXT", nullable: false),
CoverImage = table.Column<byte[]>(type: "BLOB", nullable: true),
Pages = table.Column<int>(type: "INTEGER", nullable: false),
VolumeId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Chapter", x => x.Id);
table.ForeignKey(
name: "FK_Chapter_Volume_VolumeId",
column: x => x.VolumeId,
principalTable: "Volume",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_MangaFile_ChapterId",
table: "MangaFile",
column: "ChapterId");
migrationBuilder.CreateIndex(
name: "IX_Chapter_VolumeId",
table: "Chapter",
column: "VolumeId");
migrationBuilder.AddForeignKey(
name: "FK_MangaFile_Chapter_ChapterId",
table: "MangaFile",
column: "ChapterId",
principalTable: "Chapter",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MangaFile_Chapter_ChapterId",
table: "MangaFile");
migrationBuilder.DropTable(
name: "Chapter");
migrationBuilder.DropIndex(
name: "IX_MangaFile_ChapterId",
table: "MangaFile");
migrationBuilder.DropColumn(
name: "IsSpecial",
table: "Volume");
migrationBuilder.DropColumn(
name: "ChapterId",
table: "MangaFile");
migrationBuilder.DropColumn(
name: "LastScanned",
table: "FolderPath");
migrationBuilder.DropColumn(
name: "ChapterId",
table: "AppUserProgresses");
}
}
}