Kavita/API/Data/Migrations/20201229190216_SeriesAndVolumeEntities.cs

130 lines
4.8 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace API.Data.Migrations
{
public partial class SeriesAndVolumeEntities : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PasswordSalt",
table: "AspNetUsers");
migrationBuilder.AlterColumn<string>(
name: "PasswordHash",
table: "AspNetUsers",
type: "TEXT",
nullable: true,
oldClrType: typeof(byte[]),
oldType: "BLOB",
oldNullable: true);
migrationBuilder.CreateTable(
name: "Series",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true),
OriginalName = table.Column<string>(type: "TEXT", nullable: true),
SortName = table.Column<string>(type: "TEXT", nullable: true),
Summary = table.Column<string>(type: "TEXT", nullable: true),
LibraryId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Series", x => x.Id);
table.ForeignKey(
name: "FK_Series_Library_LibraryId",
column: x => x.LibraryId,
principalTable: "Library",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Volume",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Number = table.Column<string>(type: "TEXT", nullable: true),
SeriesId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Volume", x => x.Id);
table.ForeignKey(
name: "FK_Volume_Series_SeriesId",
column: x => x.SeriesId,
principalTable: "Series",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MangaFile",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
FilePath = table.Column<string>(type: "TEXT", nullable: true),
VolumeId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MangaFile", x => x.Id);
table.ForeignKey(
name: "FK_MangaFile_Volume_VolumeId",
column: x => x.VolumeId,
principalTable: "Volume",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_MangaFile_VolumeId",
table: "MangaFile",
column: "VolumeId");
migrationBuilder.CreateIndex(
name: "IX_Series_LibraryId",
table: "Series",
column: "LibraryId");
migrationBuilder.CreateIndex(
name: "IX_Volume_SeriesId",
table: "Volume",
column: "SeriesId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MangaFile");
migrationBuilder.DropTable(
name: "Volume");
migrationBuilder.DropTable(
name: "Series");
migrationBuilder.AlterColumn<byte[]>(
name: "PasswordHash",
table: "AspNetUsers",
type: "BLOB",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AddColumn<byte[]>(
name: "PasswordSalt",
table: "AspNetUsers",
type: "BLOB",
nullable: true);
}
}
}