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( name: "ZoneId", table: "TaskHeaderHistory", type: "int", nullable: false, defaultValue: 0, comment: "库区"); migrationBuilder.AddColumn( name: "ZoneId", table: "TaskHeader", type: "int", nullable: false, defaultValue: 0, comment: "库区"); migrationBuilder.AlterColumn( 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( 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( 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( 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( name: "Type", table: "Location", type: "smallint", nullable: false, comment: "库位类型", oldClrType: typeof(string), oldType: "varchar(50)", oldMaxLength: 50, oldComment: "库位类型") .OldAnnotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( 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( 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( name: "ContainerStatus", table: "Location", type: "varchar(50)", maxLength: 50, nullable: true, comment: "库位状态") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "ZoneId", table: "Location", type: "int", nullable: false, defaultValue: 0, comment: "库位编码"); migrationBuilder.AlterColumn( 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( 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( 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( name: "ZoneId", table: "Inventory", type: "int", nullable: false, defaultValue: 0, comment: "库区"); migrationBuilder.AddColumn( name: "ZoneId", table: "Container", type: "int", nullable: false, defaultValue: 0, comment: "库区"); migrationBuilder.CreateTable( name: "Customer", columns: table => new { ID = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Code = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "编码") .Annotation("MySql:CharSet", "utf8mb4"), Type = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "类型") .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "名称") .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "") .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), UpdateBy = table.Column(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(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), ZoneCode = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "库区") .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "名称") .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "") .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), UpdateBy = table.Column(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(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), MaterialCode = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "物料编码") .Annotation("MySql:CharSet", "utf8mb4"), ProcessCode = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "工序编码") .Annotation("MySql:CharSet", "utf8mb4"), ProcessName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "工序名称") .Annotation("MySql:CharSet", "utf8mb4"), ProcessOrder = table.Column(type: "int", nullable: false, comment: "工序顺序"), Weight = table.Column(type: "int", nullable: false, comment: "毛重"), Description = table.Column(type: "varchar(500)", maxLength: 500, nullable: true, comment: "工序描述") .Annotation("MySql:CharSet", "utf8mb4"), IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "是否启用"), CreateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "") .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), UpdateBy = table.Column(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(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Code = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "工序编码") .Annotation("MySql:CharSet", "utf8mb4"), Name = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "工序名称") .Annotation("MySql:CharSet", "utf8mb4"), Zone = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "存放区域") .Annotation("MySql:CharSet", "utf8mb4"), Port = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "出口") .Annotation("MySql:CharSet", "utf8mb4"), Spare1 = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "备用1") .Annotation("MySql:CharSet", "utf8mb4"), Spare2 = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "备用2") .Annotation("MySql:CharSet", "utf8mb4"), Spare3 = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "备用3") .Annotation("MySql:CharSet", "utf8mb4"), CreateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), CreateBy = table.Column(type: "varchar(50)", maxLength: 50, nullable: true, comment: "") .Annotation("MySql:CharSet", "utf8mb4"), UpdateTime = table.Column(type: "datetime(6)", nullable: true, comment: ""), UpdateBy = table.Column(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( name: "ZoneCode", table: "TaskHeaderHistory", type: "varchar(50)", maxLength: 50, nullable: true, comment: "库区") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "ZoneCode", table: "TaskHeader", type: "varchar(50)", maxLength: 50, nullable: true, comment: "库区") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( 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( name: "Qty", table: "Material", type: "decimal(12,4)", nullable: true, comment: "数量", oldClrType: typeof(decimal), oldType: "decimal(12,4)", oldComment: "数量"); migrationBuilder.AlterColumn( 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( 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( name: "QRCode", table: "Material", type: "varchar(50)", maxLength: 50, nullable: true, comment: "二维码") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "SourceCode", table: "Material", type: "varchar(50)", maxLength: 50, nullable: true, comment: "上游单号") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "UniqueCode", table: "Material", type: "varchar(50)", maxLength: 50, nullable: true, comment: "唯一码") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( name: "Type", table: "Location", type: "varchar(50)", maxLength: 50, nullable: false, comment: "库位类型", oldClrType: typeof(short), oldType: "smallint", oldComment: "库位类型") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( name: "Status", table: "Location", type: "varchar(50)", maxLength: 50, nullable: true, comment: "库位状态", oldClrType: typeof(short), oldType: "smallint", oldComment: "是否锁定") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( name: "RowFlag", table: "Location", type: "smallint", nullable: true, comment: "内外标识,0:外仓位,1:里仓位", oldClrType: typeof(short), oldType: "smallint", oldComment: "内外标识,0:外仓位,1:里仓位"); migrationBuilder.AddColumn( name: "ZoneCode", table: "Location", type: "varchar(50)", maxLength: 50, nullable: true, comment: "库区") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( 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( name: "TaskStatus", table: "Inventory", type: "varchar(50)", maxLength: 50, nullable: true, comment: "任务状态", oldClrType: typeof(short), oldType: "smallint", oldComment: "任务状态") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( 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( name: "ZoneCode", table: "Inventory", type: "varchar(50)", maxLength: 50, nullable: true, comment: "库区") .Annotation("MySql:CharSet", "utf8mb4"); } } }