using System; using Microsoft.EntityFrameworkCore.Migrations; namespace API.Data.Migrations { public partial class ReadingLists : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "ReadingList", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Title = table.Column(type: "TEXT", nullable: true), Summary = table.Column(type: "TEXT", nullable: true), Promoted = table.Column(type: "INTEGER", nullable: false), Created = table.Column(type: "TEXT", nullable: false), LastModified = table.Column(type: "TEXT", nullable: false), AppUserId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ReadingList", x => x.Id); table.ForeignKey( name: "FK_ReadingList_AspNetUsers_AppUserId", column: x => x.AppUserId, principalTable: "AspNetUsers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ReadingListItem", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), LibraryId = table.Column(type: "INTEGER", nullable: false), SeriesId = table.Column(type: "INTEGER", nullable: false), VolumeId = table.Column(type: "INTEGER", nullable: false), ChapterId = table.Column(type: "INTEGER", nullable: false), Order = table.Column(type: "INTEGER", nullable: false), ReadingListId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ReadingListItem", x => x.Id); table.ForeignKey( name: "FK_ReadingListItem_ReadingList_ReadingListId", column: x => x.ReadingListId, principalTable: "ReadingList", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_ReadingList_AppUserId", table: "ReadingList", column: "AppUserId"); migrationBuilder.CreateIndex( name: "IX_ReadingListItem_ReadingListId", table: "ReadingListItem", column: "ReadingListId"); migrationBuilder.CreateIndex( name: "IX_ReadingListItem_SeriesId_VolumeId_ChapterId_LibraryId", table: "ReadingListItem", columns: new[] { "SeriesId", "VolumeId", "ChapterId", "LibraryId" }, unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ReadingListItem"); migrationBuilder.DropTable( name: "ReadingList"); } } }