Final step of removing inventory quantity tracking - see docs/superpowers/specs/2026-08-01-remove-inventory-quantity-tracking-design.md. Destructive to any existing on-hand/transaction data; confirmed acceptable since nothing read it automatically.
74 lines
2.8 KiB
C#
74 lines
2.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CutList.Web.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class RemoveInventoryQuantityTracking : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "StockTransactions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "QuantityOnHand",
|
|
table: "StockItems");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "QuantityOnHand",
|
|
table: "StockItems",
|
|
type: "int",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "StockTransactions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
JobId = table.Column<int>(type: "int", nullable: true),
|
|
StockItemId = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"),
|
|
Notes = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
|
Quantity = table.Column<int>(type: "int", nullable: false),
|
|
Type = table.Column<int>(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");
|
|
}
|
|
}
|
|
}
|