mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
6.2 KiB
153 lines
6.2 KiB
using Microsoft.EntityFrameworkCore.Migrations; |
|
|
|
#nullable disable |
|
|
|
namespace ErsatzTV.Infrastructure.Sqlite.Migrations |
|
{ |
|
/// <inheritdoc /> |
|
public partial class Add_Block : Migration |
|
{ |
|
/// <inheritdoc /> |
|
protected override void Up(MigrationBuilder migrationBuilder) |
|
{ |
|
migrationBuilder.CreateTable( |
|
name: "BlockGroup", |
|
columns: table => new |
|
{ |
|
Id = table.Column<int>(type: "INTEGER", nullable: false) |
|
.Annotation("Sqlite:Autoincrement", true), |
|
Name = table.Column<string>(type: "TEXT", nullable: true) |
|
}, |
|
constraints: table => |
|
{ |
|
table.PrimaryKey("PK_BlockGroup", x => x.Id); |
|
}); |
|
|
|
migrationBuilder.CreateTable( |
|
name: "Block", |
|
columns: table => new |
|
{ |
|
Id = table.Column<int>(type: "INTEGER", nullable: false) |
|
.Annotation("Sqlite:Autoincrement", true), |
|
BlockGroupId = table.Column<int>(type: "INTEGER", nullable: false), |
|
Name = table.Column<string>(type: "TEXT", nullable: true), |
|
Minutes = table.Column<int>(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<int>(type: "INTEGER", nullable: false) |
|
.Annotation("Sqlite:Autoincrement", true), |
|
Index = table.Column<int>(type: "INTEGER", nullable: false), |
|
BlockId = table.Column<int>(type: "INTEGER", nullable: false), |
|
CollectionType = table.Column<int>(type: "INTEGER", nullable: false), |
|
CollectionId = table.Column<int>(type: "INTEGER", nullable: true), |
|
MediaItemId = table.Column<int>(type: "INTEGER", nullable: true), |
|
MultiCollectionId = table.Column<int>(type: "INTEGER", nullable: true), |
|
SmartCollectionId = table.Column<int>(type: "INTEGER", nullable: true), |
|
PlaybackOrder = table.Column<int>(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"); |
|
} |
|
|
|
/// <inheritdoc /> |
|
protected override void Down(MigrationBuilder migrationBuilder) |
|
{ |
|
migrationBuilder.DropTable( |
|
name: "BlockItem"); |
|
|
|
migrationBuilder.DropTable( |
|
name: "Block"); |
|
|
|
migrationBuilder.DropTable( |
|
name: "BlockGroup"); |
|
} |
|
} |
|
}
|
|
|