Files
BI/server/DongfangHydro.Dashboard.Api/Data/Migrations/20260710095939_ImportRealBom.cs
T

379 lines
14 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DongfangHydro.Dashboard.Api.Data.Migrations
{
/// <inheritdoc />
public partial class ImportRealBom : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedStart",
table: "ProductionOrders",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedEnd",
table: "ProductionOrders",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AddColumn<string>(
name: "DataSource",
table: "ProductionOrders",
type: "nvarchar(32)",
maxLength: 32,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "DrawingProductName",
table: "ProductionOrders",
type: "nvarchar(240)",
maxLength: 240,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<DateTimeOffset>(
name: "ImportedAt",
table: "ProductionOrders",
type: "datetimeoffset",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ProjectName",
table: "ProductionOrders",
type: "nvarchar(200)",
maxLength: 200,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "SourceDocumentCode",
table: "ProductionOrders",
type: "nvarchar(80)",
maxLength: 80,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "SourceFileHash",
table: "ProductionOrders",
type: "nvarchar(64)",
maxLength: 64,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "SourceFileName",
table: "ProductionOrders",
type: "nvarchar(260)",
maxLength: 260,
nullable: false,
defaultValue: "");
migrationBuilder.Sql(
"UPDATE [ProductionOrders] SET [DataSource] = 'demo' WHERE [Code] LIKE 'MO-260708-%';");
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedStart",
table: "ProductionNodes",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedEnd",
table: "ProductionNodes",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AddColumn<decimal>(
name: "BomQuantity",
table: "ProductionNodes",
type: "decimal(18,4)",
precision: 18,
scale: 4,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "BomQuantityText",
table: "ProductionNodes",
type: "nvarchar(80)",
maxLength: 80,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Material",
table: "ProductionNodes",
type: "nvarchar(120)",
maxLength: 120,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Remark",
table: "ProductionNodes",
type: "nvarchar(500)",
maxLength: 500,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<int>(
name: "SourceRow",
table: "ProductionNodes",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "SourceSequence",
table: "ProductionNodes",
type: "nvarchar(40)",
maxLength: 40,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "SourceSheet",
table: "ProductionNodes",
type: "nvarchar(40)",
maxLength: 40,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<string>(
name: "Specification",
table: "ProductionNodes",
type: "nvarchar(240)",
maxLength: 240,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<decimal>(
name: "TotalWeight",
table: "ProductionNodes",
type: "decimal(18,4)",
precision: 18,
scale: 4,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "TotalWeightText",
table: "ProductionNodes",
type: "nvarchar(80)",
maxLength: 80,
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<decimal>(
name: "UnitWeight",
table: "ProductionNodes",
type: "decimal(18,4)",
precision: 18,
scale: 4,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "UnitWeightText",
table: "ProductionNodes",
type: "nvarchar(80)",
maxLength: 80,
nullable: false,
defaultValue: "");
migrationBuilder.CreateTable(
name: "MaterialQuotas",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
OrderId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Category = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
SourceSequence = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
MaterialCode = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
MaterialName = table.Column<string>(type: "nvarchar(240)", maxLength: 240, nullable: false),
Specification = table.Column<string>(type: "nvarchar(240)", maxLength: 240, nullable: false),
Unit = table.Column<string>(type: "nvarchar(24)", maxLength: 24, nullable: false),
Quantity = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
NetWeight = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
ConsumptionQuota = table.Column<decimal>(type: "decimal(18,4)", precision: 18, scale: 4, nullable: true),
QuantityText = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
NetWeightText = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
ConsumptionQuotaText = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
Brand = table.Column<string>(type: "nvarchar(120)", maxLength: 120, nullable: false),
Remark = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: false),
SourceSheet = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false),
SourceRow = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MaterialQuotas", x => x.Id);
table.ForeignKey(
name: "FK_MaterialQuotas_ProductionOrders_OrderId",
column: x => x.OrderId,
principalTable: "ProductionOrders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ProductionOrders_SourceDocumentCode",
table: "ProductionOrders",
column: "SourceDocumentCode",
unique: true,
filter: "[SourceDocumentCode] <> ''");
migrationBuilder.CreateIndex(
name: "IX_MaterialQuotas_OrderId_Category_MaterialCode",
table: "MaterialQuotas",
columns: new[] { "OrderId", "Category", "MaterialCode" });
migrationBuilder.CreateIndex(
name: "IX_MaterialQuotas_OrderId_SourceSheet_SourceRow",
table: "MaterialQuotas",
columns: new[] { "OrderId", "SourceSheet", "SourceRow" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "MaterialQuotas");
migrationBuilder.DropIndex(
name: "IX_ProductionOrders_SourceDocumentCode",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "DataSource",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "DrawingProductName",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "ImportedAt",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "ProjectName",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "SourceDocumentCode",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "SourceFileHash",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "SourceFileName",
table: "ProductionOrders");
migrationBuilder.DropColumn(
name: "BomQuantity",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "BomQuantityText",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "Material",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "Remark",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "SourceRow",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "SourceSequence",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "SourceSheet",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "Specification",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "TotalWeight",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "TotalWeightText",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "UnitWeight",
table: "ProductionNodes");
migrationBuilder.DropColumn(
name: "UnitWeightText",
table: "ProductionNodes");
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedStart",
table: "ProductionOrders",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedEnd",
table: "ProductionOrders",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedStart",
table: "ProductionNodes",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "PlannedEnd",
table: "ProductionNodes",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
}
}
}