using System; using Microsoft.EntityFrameworkCore.Migrations; namespace API.Data.Migrations { public partial class SeriesVolumeChapterChange : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "IsSpecial", table: "Volume", type: "INTEGER", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "ChapterId", table: "MangaFile", type: "INTEGER", nullable: true); migrationBuilder.AddColumn( name: "LastScanned", table: "FolderPath", type: "TEXT", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); migrationBuilder.AddColumn( name: "ChapterId", table: "AppUserProgresses", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.CreateTable( name: "Chapter", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Range = table.Column(type: "TEXT", nullable: true), Number = table.Column(type: "TEXT", nullable: true), Created = table.Column(type: "TEXT", nullable: false), LastModified = table.Column(type: "TEXT", nullable: false), CoverImage = table.Column(type: "BLOB", nullable: true), Pages = table.Column(type: "INTEGER", nullable: false), VolumeId = table.Column(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"); } } }