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( 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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: true), OriginalName = table.Column(type: "TEXT", nullable: true), SortName = table.Column(type: "TEXT", nullable: true), Summary = table.Column(type: "TEXT", nullable: true), LibraryId = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Number = table.Column(type: "TEXT", nullable: true), SeriesId = table.Column(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(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), FilePath = table.Column(type: "TEXT", nullable: true), VolumeId = table.Column(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( name: "PasswordHash", table: "AspNetUsers", type: "BLOB", nullable: true, oldClrType: typeof(string), oldType: "TEXT", oldNullable: true); migrationBuilder.AddColumn( name: "PasswordSalt", table: "AspNetUsers", type: "BLOB", nullable: true); } } }