using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PARR.DAL.Migrations { /// public partial class tblUnitsInTemplates : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropIndex( name: "IX_Templates_Name", table: "Templates"); migrationBuilder.AddColumn( name: "Index", table: "Templates", type: "integer", nullable: true); migrationBuilder.AddColumn( name: "IsUnused", table: "Templates", type: "boolean", nullable: false, defaultValue: false); migrationBuilder.CreateTable( name: "UnitsInTemplates", schema: "job", columns: table => new { TemplateId = table.Column(type: "uuid", nullable: false), UnitId = table.Column(type: "uuid", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UnitsInTemplates", x => new { x.TemplateId, x.UnitId }); table.ForeignKey( name: "FK_UnitsInTemplates_Templates_TemplateId", column: x => x.TemplateId, principalTable: "Templates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_UnitsInTemplates_Units_UnitId", column: x => x.UnitId, principalSchema: "unit", principalTable: "Units", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }, comment: "Таблица связи ЭК в шаблонах"); migrationBuilder.CreateIndex( name: "IX_Templates_Name_Index", table: "Templates", columns: new[] { "Name", "Index" }, unique: true); migrationBuilder.CreateIndex( name: "IX_UnitsInTemplates_UnitId", schema: "job", table: "UnitsInTemplates", column: "UnitId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "UnitsInTemplates", schema: "job"); migrationBuilder.DropIndex( name: "IX_Templates_Name_Index", table: "Templates"); migrationBuilder.DropColumn( name: "Index", table: "Templates"); migrationBuilder.DropColumn( name: "IsUnused", table: "Templates"); migrationBuilder.CreateIndex( name: "IX_Templates_Name", table: "Templates", column: "Name", unique: true); } } }