using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FabWorks.Core.Migrations { /// public partial class AddDrawingEntity : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "DrawingId", table: "ExportRecords", type: "int", nullable: true); migrationBuilder.CreateTable( name: "Drawings", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DrawingNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), Title = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), PdfContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), Revision = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Drawings", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_ExportRecords_DrawingId", table: "ExportRecords", column: "DrawingId"); migrationBuilder.CreateIndex( name: "IX_Drawings_DrawingNumber", table: "Drawings", column: "DrawingNumber", unique: true, filter: "[DrawingNumber] IS NOT NULL"); migrationBuilder.AddForeignKey( name: "FK_ExportRecords_Drawings_DrawingId", table: "ExportRecords", column: "DrawingId", principalTable: "Drawings", principalColumn: "Id", onDelete: ReferentialAction.SetNull); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_ExportRecords_Drawings_DrawingId", table: "ExportRecords"); migrationBuilder.DropTable( name: "Drawings"); migrationBuilder.DropIndex( name: "IX_ExportRecords_DrawingId", table: "ExportRecords"); migrationBuilder.DropColumn( name: "DrawingId", table: "ExportRecords"); } } }