using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace CutList.Web.Migrations { /// public partial class RemoveInventoryQuantityTracking : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "StockTransactions"); migrationBuilder.DropColumn( name: "QuantityOnHand", table: "StockItems"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "QuantityOnHand", table: "StockItems", type: "int", nullable: false, defaultValue: 0); migrationBuilder.CreateTable( name: "StockTransactions", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), JobId = table.Column(type: "int", nullable: true), StockItemId = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"), Notes = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), Quantity = table.Column(type: "int", nullable: false), Type = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_StockTransactions", x => x.Id); table.ForeignKey( name: "FK_StockTransactions_Jobs_JobId", column: x => x.JobId, principalTable: "Jobs", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_StockTransactions_StockItems_StockItemId", column: x => x.StockItemId, principalTable: "StockItems", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_StockTransactions_JobId", table: "StockTransactions", column: "JobId"); migrationBuilder.CreateIndex( name: "IX_StockTransactions_StockItemId", table: "StockTransactions", column: "StockItemId"); } } }