using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace CutList.Web.Migrations { /// public partial class AddPurchaseItem : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "PurchaseItems", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), StockItemId = table.Column(type: "int", nullable: false), SupplierId = table.Column(type: "int", nullable: true), Quantity = table.Column(type: "int", nullable: false), JobId = table.Column(type: "int", nullable: true), Notes = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), Status = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"), UpdatedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_PurchaseItems", x => x.Id); table.ForeignKey( name: "FK_PurchaseItems_Jobs_JobId", column: x => x.JobId, principalTable: "Jobs", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_PurchaseItems_StockItems_StockItemId", column: x => x.StockItemId, principalTable: "StockItems", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_PurchaseItems_Suppliers_SupplierId", column: x => x.SupplierId, principalTable: "Suppliers", principalColumn: "Id", onDelete: ReferentialAction.SetNull); }); migrationBuilder.CreateIndex( name: "IX_PurchaseItems_JobId", table: "PurchaseItems", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_PurchaseItems_StockItemId", table: "PurchaseItems", column: "StockItemId"); migrationBuilder.CreateIndex( name: "IX_PurchaseItems_SupplierId", table: "PurchaseItems", column: "SupplierId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "PurchaseItems"); } } }