using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ErsatzTV.Infrastructure.Sqlite.Migrations { /// public partial class Add_Block : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "BlockGroup", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Name = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_BlockGroup", x => x.Id); }); migrationBuilder.CreateTable( name: "Block", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), BlockGroupId = table.Column(type: "INTEGER", nullable: false), Name = table.Column(type: "TEXT", nullable: true), Minutes = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Block", x => x.Id); table.ForeignKey( name: "FK_Block_BlockGroup_BlockGroupId", column: x => x.BlockGroupId, principalTable: "BlockGroup", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "BlockItem", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Index = table.Column(type: "INTEGER", nullable: false), BlockId = table.Column(type: "INTEGER", nullable: false), CollectionType = table.Column(type: "INTEGER", nullable: false), CollectionId = table.Column(type: "INTEGER", nullable: true), MediaItemId = table.Column(type: "INTEGER", nullable: true), MultiCollectionId = table.Column(type: "INTEGER", nullable: true), SmartCollectionId = table.Column(type: "INTEGER", nullable: true), PlaybackOrder = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_BlockItem", x => x.Id); table.ForeignKey( name: "FK_BlockItem_Block_BlockId", column: x => x.BlockId, principalTable: "Block", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_BlockItem_Collection_CollectionId", column: x => x.CollectionId, principalTable: "Collection", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_BlockItem_MediaItem_MediaItemId", column: x => x.MediaItemId, principalTable: "MediaItem", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_BlockItem_MultiCollection_MultiCollectionId", column: x => x.MultiCollectionId, principalTable: "MultiCollection", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_BlockItem_SmartCollection_SmartCollectionId", column: x => x.SmartCollectionId, principalTable: "SmartCollection", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Block_BlockGroupId", table: "Block", column: "BlockGroupId"); migrationBuilder.CreateIndex( name: "IX_Block_Name", table: "Block", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_BlockGroup_Name", table: "BlockGroup", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_BlockItem_BlockId", table: "BlockItem", column: "BlockId"); migrationBuilder.CreateIndex( name: "IX_BlockItem_CollectionId", table: "BlockItem", column: "CollectionId"); migrationBuilder.CreateIndex( name: "IX_BlockItem_MediaItemId", table: "BlockItem", column: "MediaItemId"); migrationBuilder.CreateIndex( name: "IX_BlockItem_MultiCollectionId", table: "BlockItem", column: "MultiCollectionId"); migrationBuilder.CreateIndex( name: "IX_BlockItem_SmartCollectionId", table: "BlockItem", column: "SmartCollectionId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "BlockItem"); migrationBuilder.DropTable( name: "Block"); migrationBuilder.DropTable( name: "BlockGroup"); } } }