using System; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace FictionArchive.Service.UserNovelDataService.Migrations { /// public partial class AddReadingLists : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "ReadingLists", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: true), CreatedTime = table.Column(type: "timestamp with time zone", nullable: false), LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ReadingLists", x => x.Id); table.ForeignKey( name: "FK_ReadingLists_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ReadingListItems", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ReadingListId = table.Column(type: "integer", nullable: false), NovelId = table.Column(type: "bigint", nullable: false), Order = table.Column(type: "integer", nullable: false), CreatedTime = table.Column(type: "timestamp with time zone", nullable: false), LastUpdatedTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ReadingListItems", x => x.Id); table.ForeignKey( name: "FK_ReadingListItems_ReadingLists_ReadingListId", column: x => x.ReadingListId, principalTable: "ReadingLists", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_ReadingListItems_ReadingListId_NovelId", table: "ReadingListItems", columns: new[] { "ReadingListId", "NovelId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_ReadingListItems_ReadingListId_Order", table: "ReadingListItems", columns: new[] { "ReadingListId", "Order" }); migrationBuilder.CreateIndex( name: "IX_ReadingLists_UserId", table: "ReadingLists", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ReadingListItems"); migrationBuilder.DropTable( name: "ReadingLists"); } } }