Files
WMS/HHWMS.Web/Migrations/20250901175231_wms3.cs

692 lines
28 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace HHWMS.Web.Migrations
{
public partial class wms3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ZoneCode",
table: "TaskHeaderHistory");
migrationBuilder.DropColumn(
name: "ZoneCode",
table: "TaskHeader");
migrationBuilder.DropColumn(
name: "QRCode",
table: "Material");
migrationBuilder.DropColumn(
name: "SourceCode",
table: "Material");
migrationBuilder.DropColumn(
name: "UniqueCode",
table: "Material");
migrationBuilder.DropColumn(
name: "ZoneCode",
table: "Location");
migrationBuilder.DropColumn(
name: "ZoneCode",
table: "Inventory");
migrationBuilder.AddColumn<int>(
name: "ZoneId",
table: "TaskHeaderHistory",
type: "int",
nullable: false,
defaultValue: 0,
comment: "库区");
migrationBuilder.AddColumn<int>(
name: "ZoneId",
table: "TaskHeader",
type: "int",
nullable: false,
defaultValue: 0,
comment: "库区");
migrationBuilder.AlterColumn<string>(
name: "SupplierCode",
table: "Material",
type: "varchar(100)",
maxLength: 100,
nullable: true,
comment: "供应商",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "供应商")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<decimal>(
name: "Qty",
table: "Material",
type: "decimal(12,4)",
nullable: false,
defaultValue: 0m,
comment: "数量",
oldClrType: typeof(decimal),
oldType: "decimal(12,4)",
oldNullable: true,
oldComment: "数量");
migrationBuilder.UpdateData(
table: "Material",
keyColumn: "MaterialType",
keyValue: null,
column: "MaterialType",
value: "");
migrationBuilder.AlterColumn<string>(
name: "MaterialType",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: false,
comment: "物料类型",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "物料类型")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "Material",
keyColumn: "MaterialCode",
keyValue: null,
column: "MaterialCode",
value: "");
migrationBuilder.AlterColumn<string>(
name: "MaterialCode",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: false,
comment: "物料编码",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "物料编码")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<short>(
name: "Type",
table: "Location",
type: "smallint",
nullable: false,
comment: "库位类型",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldComment: "库位类型")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<short>(
name: "Status",
table: "Location",
type: "smallint",
nullable: false,
defaultValue: (short)0,
comment: "是否锁定",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "库位状态")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<short>(
name: "RowFlag",
table: "Location",
type: "smallint",
nullable: false,
defaultValue: (short)0,
comment: "内外标识,0:外仓位,1:里仓位",
oldClrType: typeof(short),
oldType: "smallint",
oldNullable: true,
oldComment: "内外标识,0:外仓位,1:里仓位");
migrationBuilder.AddColumn<string>(
name: "ContainerStatus",
table: "Location",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "库位状态")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "ZoneId",
table: "Location",
type: "int",
nullable: false,
defaultValue: 0,
comment: "库位编码");
migrationBuilder.AlterColumn<string>(
name: "SupplierCode",
table: "InventoryTransaction",
type: "varchar(100)",
maxLength: 100,
nullable: true,
comment: "供应商",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "供应商")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<short>(
name: "TaskStatus",
table: "Inventory",
type: "smallint",
nullable: false,
defaultValue: (short)0,
comment: "任务状态",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "任务状态")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "SupplierCode",
table: "Inventory",
type: "varchar(100)",
maxLength: 100,
nullable: true,
comment: "供应商",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldNullable: true,
oldComment: "供应商")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "ZoneId",
table: "Inventory",
type: "int",
nullable: false,
defaultValue: 0,
comment: "库区");
migrationBuilder.AddColumn<int>(
name: "ZoneId",
table: "Container",
type: "int",
nullable: false,
defaultValue: 0,
comment: "库区");
migrationBuilder.CreateTable(
name: "Customer",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Code = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "编码")
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "类型")
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "名称")
.Annotation("MySql:CharSet", "utf8mb4"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Customer", x => x.ID);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "LocationZone",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ZoneCode = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "库区")
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "名称")
.Annotation("MySql:CharSet", "utf8mb4"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_LocationZone", x => x.ID);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "MaterialProcess",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
MaterialCode = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "物料编码")
.Annotation("MySql:CharSet", "utf8mb4"),
ProcessCode = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "工序编码")
.Annotation("MySql:CharSet", "utf8mb4"),
ProcessName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false, comment: "工序名称")
.Annotation("MySql:CharSet", "utf8mb4"),
ProcessOrder = table.Column<int>(type: "int", nullable: false, comment: "工序顺序"),
Weight = table.Column<int>(type: "int", nullable: false, comment: "毛重"),
Description = table.Column<string>(type: "varchar(500)", maxLength: 500, nullable: true, comment: "工序描述")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "是否启用"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_MaterialProcess", x => x.ID);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ProcessConfig",
columns: table => new
{
ID = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Code = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "工序编码")
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "工序名称")
.Annotation("MySql:CharSet", "utf8mb4"),
Zone = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "存放区域")
.Annotation("MySql:CharSet", "utf8mb4"),
Port = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "出口")
.Annotation("MySql:CharSet", "utf8mb4"),
Spare1 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "备用1")
.Annotation("MySql:CharSet", "utf8mb4"),
Spare2 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "备用2")
.Annotation("MySql:CharSet", "utf8mb4"),
Spare3 = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "备用3")
.Annotation("MySql:CharSet", "utf8mb4"),
CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
CreateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4"),
UpdateTime = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: ""),
UpdateBy = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_ProcessConfig", x => x.ID);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_TaskHeaderHistory_ZoneId",
table: "TaskHeaderHistory",
column: "ZoneId");
migrationBuilder.CreateIndex(
name: "IX_TaskHeader_ZoneId",
table: "TaskHeader",
column: "ZoneId");
migrationBuilder.CreateIndex(
name: "IX_Location_ZoneId",
table: "Location",
column: "ZoneId");
migrationBuilder.CreateIndex(
name: "IX_Inventory_ZoneId",
table: "Inventory",
column: "ZoneId");
migrationBuilder.CreateIndex(
name: "IX_Container_ZoneId",
table: "Container",
column: "ZoneId");
migrationBuilder.AddForeignKey(
name: "FK_Container_LocationZone_ZoneId",
table: "Container",
column: "ZoneId",
principalTable: "LocationZone",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Inventory_LocationZone_ZoneId",
table: "Inventory",
column: "ZoneId",
principalTable: "LocationZone",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Location_LocationZone_ZoneId",
table: "Location",
column: "ZoneId",
principalTable: "LocationZone",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_TaskHeader_LocationZone_ZoneId",
table: "TaskHeader",
column: "ZoneId",
principalTable: "LocationZone",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_TaskHeaderHistory_LocationZone_ZoneId",
table: "TaskHeaderHistory",
column: "ZoneId",
principalTable: "LocationZone",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Container_LocationZone_ZoneId",
table: "Container");
migrationBuilder.DropForeignKey(
name: "FK_Inventory_LocationZone_ZoneId",
table: "Inventory");
migrationBuilder.DropForeignKey(
name: "FK_Location_LocationZone_ZoneId",
table: "Location");
migrationBuilder.DropForeignKey(
name: "FK_TaskHeader_LocationZone_ZoneId",
table: "TaskHeader");
migrationBuilder.DropForeignKey(
name: "FK_TaskHeaderHistory_LocationZone_ZoneId",
table: "TaskHeaderHistory");
migrationBuilder.DropTable(
name: "Customer");
migrationBuilder.DropTable(
name: "LocationZone");
migrationBuilder.DropTable(
name: "MaterialProcess");
migrationBuilder.DropTable(
name: "ProcessConfig");
migrationBuilder.DropIndex(
name: "IX_TaskHeaderHistory_ZoneId",
table: "TaskHeaderHistory");
migrationBuilder.DropIndex(
name: "IX_TaskHeader_ZoneId",
table: "TaskHeader");
migrationBuilder.DropIndex(
name: "IX_Location_ZoneId",
table: "Location");
migrationBuilder.DropIndex(
name: "IX_Inventory_ZoneId",
table: "Inventory");
migrationBuilder.DropIndex(
name: "IX_Container_ZoneId",
table: "Container");
migrationBuilder.DropColumn(
name: "ZoneId",
table: "TaskHeaderHistory");
migrationBuilder.DropColumn(
name: "ZoneId",
table: "TaskHeader");
migrationBuilder.DropColumn(
name: "ContainerStatus",
table: "Location");
migrationBuilder.DropColumn(
name: "ZoneId",
table: "Location");
migrationBuilder.DropColumn(
name: "ZoneId",
table: "Inventory");
migrationBuilder.DropColumn(
name: "ZoneId",
table: "Container");
migrationBuilder.AddColumn<string>(
name: "ZoneCode",
table: "TaskHeaderHistory",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "库区")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ZoneCode",
table: "TaskHeader",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "库区")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "SupplierCode",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "供应商",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldNullable: true,
oldComment: "供应商")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<decimal>(
name: "Qty",
table: "Material",
type: "decimal(12,4)",
nullable: true,
comment: "数量",
oldClrType: typeof(decimal),
oldType: "decimal(12,4)",
oldComment: "数量");
migrationBuilder.AlterColumn<string>(
name: "MaterialType",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "物料类型",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldComment: "物料类型")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "MaterialCode",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "物料编码",
oldClrType: typeof(string),
oldType: "varchar(50)",
oldMaxLength: 50,
oldComment: "物料编码")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "QRCode",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "二维码")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "SourceCode",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "上游单号")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "UniqueCode",
table: "Material",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "唯一码")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Type",
table: "Location",
type: "varchar(50)",
maxLength: 50,
nullable: false,
comment: "库位类型",
oldClrType: typeof(short),
oldType: "smallint",
oldComment: "库位类型")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Status",
table: "Location",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "库位状态",
oldClrType: typeof(short),
oldType: "smallint",
oldComment: "是否锁定")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<short>(
name: "RowFlag",
table: "Location",
type: "smallint",
nullable: true,
comment: "内外标识,0:外仓位,1:里仓位",
oldClrType: typeof(short),
oldType: "smallint",
oldComment: "内外标识,0:外仓位,1:里仓位");
migrationBuilder.AddColumn<string>(
name: "ZoneCode",
table: "Location",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "库区")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "SupplierCode",
table: "InventoryTransaction",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "供应商",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldNullable: true,
oldComment: "供应商")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "TaskStatus",
table: "Inventory",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "任务状态",
oldClrType: typeof(short),
oldType: "smallint",
oldComment: "任务状态")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "SupplierCode",
table: "Inventory",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "供应商",
oldClrType: typeof(string),
oldType: "varchar(100)",
oldMaxLength: 100,
oldNullable: true,
oldComment: "供应商")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ZoneCode",
table: "Inventory",
type: "varchar(50)",
maxLength: 50,
nullable: true,
comment: "库区")
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}