184 lines
7.8 KiB
C#
184 lines
7.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CutList.Web.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class RemoveVendorData : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_StockTransactions_Suppliers_SupplierId",
|
|
table: "StockTransactions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PurchaseItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "SupplierOfferings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Suppliers");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_StockTransactions_SupplierId",
|
|
table: "StockTransactions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "SupplierId",
|
|
table: "StockTransactions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "UnitPrice",
|
|
table: "StockTransactions");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "SupplierId",
|
|
table: "StockTransactions",
|
|
type: "int",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<decimal>(
|
|
name: "UnitPrice",
|
|
table: "StockTransactions",
|
|
type: "decimal(10,2)",
|
|
precision: 10,
|
|
scale: 2,
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Suppliers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ContactInfo = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"),
|
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
|
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Suppliers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PurchaseItems",
|
|
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),
|
|
SupplierId = table.Column<int>(type: "int", nullable: true),
|
|
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),
|
|
Status = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(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.CreateTable(
|
|
name: "SupplierOfferings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
StockItemId = table.Column<int>(type: "int", nullable: false),
|
|
SupplierId = table.Column<int>(type: "int", nullable: false),
|
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
|
Notes = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
|
|
PartNumber = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
|
Price = table.Column<decimal>(type: "decimal(10,2)", precision: 10, scale: 2, nullable: true),
|
|
SupplierDescription = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_SupplierOfferings", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_SupplierOfferings_StockItems_StockItemId",
|
|
column: x => x.StockItemId,
|
|
principalTable: "StockItems",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_SupplierOfferings_Suppliers_SupplierId",
|
|
column: x => x.SupplierId,
|
|
principalTable: "Suppliers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_StockTransactions_SupplierId",
|
|
table: "StockTransactions",
|
|
column: "SupplierId");
|
|
|
|
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");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SupplierOfferings_StockItemId",
|
|
table: "SupplierOfferings",
|
|
column: "StockItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_SupplierOfferings_SupplierId_StockItemId",
|
|
table: "SupplierOfferings",
|
|
columns: new[] { "SupplierId", "StockItemId" },
|
|
unique: true);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_StockTransactions_Suppliers_SupplierId",
|
|
table: "StockTransactions",
|
|
column: "SupplierId",
|
|
principalTable: "Suppliers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
}
|
|
}
|
|
}
|