diff --git a/FabWorks.Core/Migrations/20260218113525_InitialCreate.cs b/FabWorks.Core/Migrations/20260218113525_InitialCreate.cs deleted file mode 100644 index 1a41881..0000000 --- a/FabWorks.Core/Migrations/20260218113525_InitialCreate.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace FabWorks.Core.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - // NOTE: ExportRecords, BomItems, and CutTemplates tables already exist - // in the database (created by ExportDXF's ExportDxfDbContext migrations). - // This migration only adds the new FormPrograms table. - - migrationBuilder.CreateTable( - name: "FormPrograms", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ProgramFilePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - ContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProgramName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Thickness = table.Column(type: "float", nullable: true), - MaterialType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - KFactor = table.Column(type: "float", nullable: true), - BendCount = table.Column(type: "int", nullable: false), - UpperToolNames = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - LowerToolNames = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - SetupNotes = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - BomItemId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FormPrograms", x => x.Id); - table.ForeignKey( - name: "FK_FormPrograms_BomItems_BomItemId", - column: x => x.BomItemId, - principalTable: "BomItems", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_FormPrograms_BomItemId", - table: "FormPrograms", - column: "BomItemId", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "FormPrograms"); - } - } -} diff --git a/FabWorks.Core/Migrations/20260218113525_InitialCreate.Designer.cs b/FabWorks.Core/Migrations/20260218171742_InitialCreate.Designer.cs similarity index 94% rename from FabWorks.Core/Migrations/20260218113525_InitialCreate.Designer.cs rename to FabWorks.Core/Migrations/20260218171742_InitialCreate.Designer.cs index 57ec80a..2b8a06c 100644 --- a/FabWorks.Core/Migrations/20260218113525_InitialCreate.Designer.cs +++ b/FabWorks.Core/Migrations/20260218171742_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace FabWorks.Core.Migrations { [DbContext(typeof(FabWorksDbContext))] - [Migration("20260218113525_InitialCreate")] + [Migration("20260218171742_InitialCreate")] partial class InitialCreate { /// @@ -124,10 +124,18 @@ namespace FabWorks.Core.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("DrawingNo") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.Property("DrawingNumber") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); + b.Property("EquipmentNo") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.Property("ExportedAt") .HasColumnType("datetime2"); @@ -147,6 +155,10 @@ namespace FabWorks.Core.Migrations .HasMaxLength(500) .HasColumnType("nvarchar(500)"); + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + b.HasKey("Id"); b.ToTable("ExportRecords"); diff --git a/FabWorks.Core/Migrations/20260218171742_InitialCreate.cs b/FabWorks.Core/Migrations/20260218171742_InitialCreate.cs new file mode 100644 index 0000000..77ae070 --- /dev/null +++ b/FabWorks.Core/Migrations/20260218171742_InitialCreate.cs @@ -0,0 +1,151 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace FabWorks.Core.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ExportRecords", + 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), + EquipmentNo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + DrawingNo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + SourceFilePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + OutputFolder = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + ExportedAt = table.Column(type: "datetime2", nullable: false), + ExportedBy = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + PdfContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ExportRecords", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "BomItems", + columns: table => new + { + ID = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ItemNo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + PartNo = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + SortOrder = table.Column(type: "int", nullable: false), + Qty = table.Column(type: "int", nullable: true), + TotalQty = table.Column(type: "int", nullable: true), + Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + PartName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + ConfigurationName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Material = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + ExportRecordId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BomItems", x => x.ID); + table.ForeignKey( + name: "FK_BomItems_ExportRecords_ExportRecordId", + column: x => x.ExportRecordId, + principalTable: "ExportRecords", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CutTemplates", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DxfFilePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + ContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CutTemplateName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Thickness = table.Column(type: "float", nullable: true), + KFactor = table.Column(type: "float", nullable: true), + DefaultBendRadius = table.Column(type: "float", nullable: true), + BomItemId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CutTemplates", x => x.Id); + table.ForeignKey( + name: "FK_CutTemplates_BomItems_BomItemId", + column: x => x.BomItemId, + principalTable: "BomItems", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "FormPrograms", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProgramFilePath = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + ContentHash = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProgramName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Thickness = table.Column(type: "float", nullable: true), + MaterialType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + KFactor = table.Column(type: "float", nullable: true), + BendCount = table.Column(type: "int", nullable: false), + UpperToolNames = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + LowerToolNames = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + SetupNotes = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + BomItemId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FormPrograms", x => x.Id); + table.ForeignKey( + name: "FK_FormPrograms_BomItems_BomItemId", + column: x => x.BomItemId, + principalTable: "BomItems", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_BomItems_ExportRecordId", + table: "BomItems", + column: "ExportRecordId"); + + migrationBuilder.CreateIndex( + name: "IX_CutTemplates_BomItemId", + table: "CutTemplates", + column: "BomItemId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_FormPrograms_BomItemId", + table: "FormPrograms", + column: "BomItemId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CutTemplates"); + + migrationBuilder.DropTable( + name: "FormPrograms"); + + migrationBuilder.DropTable( + name: "BomItems"); + + migrationBuilder.DropTable( + name: "ExportRecords"); + } + } +} diff --git a/FabWorks.Core/Migrations/FabWorksDbContextModelSnapshot.cs b/FabWorks.Core/Migrations/FabWorksDbContextModelSnapshot.cs index 1096f92..72ce3fb 100644 --- a/FabWorks.Core/Migrations/FabWorksDbContextModelSnapshot.cs +++ b/FabWorks.Core/Migrations/FabWorksDbContextModelSnapshot.cs @@ -121,10 +121,18 @@ namespace FabWorks.Core.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("DrawingNo") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.Property("DrawingNumber") .HasMaxLength(100) .HasColumnType("nvarchar(100)"); + b.Property("EquipmentNo") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.Property("ExportedAt") .HasColumnType("datetime2"); @@ -144,6 +152,10 @@ namespace FabWorks.Core.Migrations .HasMaxLength(500) .HasColumnType("nvarchar(500)"); + b.Property("Title") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + b.HasKey("Id"); b.ToTable("ExportRecords");