using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ErsatzTV.Infrastructure.Sqlite.Migrations { /// public partial class Add_Template : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "TemplateGroup", 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_TemplateGroup", x => x.Id); }); migrationBuilder.CreateTable( name: "Template", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), TemplateGroupId = table.Column(type: "INTEGER", nullable: false), Name = table.Column(type: "TEXT", nullable: true), PlayoutId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Template", x => x.Id); table.ForeignKey( name: "FK_Template_Playout_PlayoutId", column: x => x.PlayoutId, principalTable: "Playout", principalColumn: "Id"); table.ForeignKey( name: "FK_Template_TemplateGroup_TemplateGroupId", column: x => x.TemplateGroupId, principalTable: "TemplateGroup", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TemplateItem", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), TemplateId = table.Column(type: "INTEGER", nullable: false), BlockId = table.Column(type: "INTEGER", nullable: false), StartTime = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TemplateItem", x => x.Id); table.ForeignKey( name: "FK_TemplateItem_Block_BlockId", column: x => x.BlockId, principalTable: "Block", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TemplateItem_Template_TemplateId", column: x => x.TemplateId, principalTable: "Template", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Template_Name", table: "Template", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_Template_PlayoutId", table: "Template", column: "PlayoutId"); migrationBuilder.CreateIndex( name: "IX_Template_TemplateGroupId", table: "Template", column: "TemplateGroupId"); migrationBuilder.CreateIndex( name: "IX_TemplateGroup_Name", table: "TemplateGroup", column: "Name", unique: true); migrationBuilder.CreateIndex( name: "IX_TemplateItem_BlockId", table: "TemplateItem", column: "BlockId"); migrationBuilder.CreateIndex( name: "IX_TemplateItem_TemplateId", table: "TemplateItem", column: "TemplateId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "TemplateItem"); migrationBuilder.DropTable( name: "Template"); migrationBuilder.DropTable( name: "TemplateGroup"); } } }