using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Business.Migrations { public partial class AddIndex : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ic_item_inventory"); migrationBuilder.DropIndex( name: "IX_srm_supplier_supplier_no_tenant_id_factory_id", table: "srm_supplier"); migrationBuilder.DropIndex( name: "IX_srm_po_main_po_billno_tenant_id_factory_id", table: "srm_po_main"); migrationBuilder.DropIndex( name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id", table: "ic_bom"); migrationBuilder.DropIndex( name: "IX_crm_seorder_bill_no_tenant_id_factory_id", table: "crm_seorder"); migrationBuilder.DropIndex( name: "IX_crm_customer_customer_no_tenant_id_factory_id", table: "crm_customer"); migrationBuilder.DropColumn( name: "factory_fode", table: "ic_item_stock"); migrationBuilder.AddColumn( name: "number", table: "srm_purchase", type: "nvarchar(20)", maxLength: 20, nullable: true, comment: "物料编码"); migrationBuilder.AddColumn( name: "fversion", table: "ic_substitute_group_detail", type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "版本号"); migrationBuilder.AddColumn( name: "fversion", table: "ic_item_stock", type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "版本号"); migrationBuilder.AddColumn( name: "icitem_number", table: "ic_item_stock", type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "物料编码"); migrationBuilder.CreateIndex( name: "IX_srm_supplier_supplier_no_tenant_id_factory_id", table: "srm_supplier", columns: new[] { "supplier_no", "tenant_id", "factory_id" }, unique: true, filter: "[supplier_no] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_srm_purchase_supplier_number_number_tenant_id_factory_id", table: "srm_purchase", columns: new[] { "supplier_number", "number", "tenant_id", "factory_id" }, unique: true, filter: "[supplier_number] IS NOT NULL AND [number] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_srm_pr_main_pr_billno_tenant_id_factory_id", table: "srm_pr_main", columns: new[] { "pr_billno", "tenant_id", "factory_id" }, unique: true, filter: "[pr_billno] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_srm_po_main_po_billno_tenant_id_factory_id", table: "srm_po_main", columns: new[] { "po_billno", "tenant_id", "factory_id" }, unique: true, filter: "[po_billno] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_srm_po_list_po_billno_polist_row_tenant_id_factory_id", table: "srm_po_list", columns: new[] { "po_billno", "polist_row", "tenant_id", "factory_id" }, unique: true, filter: "[po_billno] IS NOT NULL AND [polist_row] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_ic_item_stock_icitem_number_fversion_tenant_id_factory_id", table: "ic_item_stock", columns: new[] { "icitem_number", "fversion", "tenant_id", "factory_id" }, unique: true, filter: "[icitem_number] IS NOT NULL AND [fversion] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_ic_item_number_fversion_tenant_id_factory_id", table: "ic_item", columns: new[] { "number", "fversion", "tenant_id", "factory_id" }, unique: true, filter: "[number] IS NOT NULL AND [fversion] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_ic_bom_child_bom_number_item_number_version_tenant_id_factory_id", table: "ic_bom_child", columns: new[] { "bom_number", "item_number", "version", "tenant_id", "factory_id" }, unique: true, filter: "[bom_number] IS NOT NULL AND [item_number] IS NOT NULL AND [version] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id", table: "ic_bom", columns: new[] { "bom_number", "item_number", "version", "tenant_id", "factory_id" }, unique: true, filter: "[bom_number] IS NOT NULL AND [item_number] IS NOT NULL AND [version] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_crm_seorderentry_bill_no_entry_seq_tenant_id_factory_id", table: "crm_seorderentry", columns: new[] { "bill_no", "entry_seq", "tenant_id", "factory_id" }, unique: true, filter: "[bill_no] IS NOT NULL AND [entry_seq] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_crm_seorder_bill_no_tenant_id_factory_id", table: "crm_seorder", columns: new[] { "bill_no", "tenant_id", "factory_id" }, unique: true, filter: "[bill_no] IS NOT NULL AND [factory_id] IS NOT NULL"); migrationBuilder.CreateIndex( name: "IX_crm_customer_customer_no_tenant_id_factory_id", table: "crm_customer", columns: new[] { "customer_no", "tenant_id", "factory_id" }, unique: true, filter: "[customer_no] IS NOT NULL AND [factory_id] IS NOT NULL"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropIndex( name: "IX_srm_supplier_supplier_no_tenant_id_factory_id", table: "srm_supplier"); migrationBuilder.DropIndex( name: "IX_srm_purchase_sourcelist_number_icitem_number_tenant_id_factory_id", table: "srm_purchase"); migrationBuilder.DropIndex( name: "IX_srm_pr_main_pr_billno_tenant_id_factory_id", table: "srm_pr_main"); migrationBuilder.DropIndex( name: "IX_srm_po_main_po_billno_tenant_id_factory_id", table: "srm_po_main"); migrationBuilder.DropIndex( name: "IX_srm_po_list_po_billno_polist_row_tenant_id_factory_id", table: "srm_po_list"); migrationBuilder.DropIndex( name: "IX_ic_item_stock_icitem_number_fversion_tenant_id_factory_id", table: "ic_item_stock"); migrationBuilder.DropIndex( name: "IX_ic_item_number_fversion_tenant_id_factory_id", table: "ic_item"); migrationBuilder.DropIndex( name: "IX_ic_bom_child_bom_number_item_number_version_tenant_id_factory_id", table: "ic_bom_child"); migrationBuilder.DropIndex( name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id", table: "ic_bom"); migrationBuilder.DropIndex( name: "IX_crm_seorderentry_bill_no_entry_seq_tenant_id_factory_id", table: "crm_seorderentry"); migrationBuilder.DropIndex( name: "IX_crm_seorder_bill_no_tenant_id_factory_id", table: "crm_seorder"); migrationBuilder.DropIndex( name: "IX_crm_customer_customer_no_tenant_id_factory_id", table: "crm_customer"); migrationBuilder.DropColumn( name: "icitem_number", table: "srm_purchase"); migrationBuilder.DropColumn( name: "fversion", table: "ic_substitute_group_detail"); migrationBuilder.DropColumn( name: "fversion", table: "ic_item_stock"); migrationBuilder.DropColumn( name: "icitem_number", table: "ic_item_stock"); migrationBuilder.AddColumn( name: "factory_fode", table: "ic_item_stock", type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "工厂编码"); migrationBuilder.CreateTable( name: "ic_item_inventory", columns: table => new { Id = table.Column(type: "bigint", nullable: false), IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false, comment: "删除标识"), bal = table.Column(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "金额"), batch_no = table.Column(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "批次号"), create_by = table.Column(type: "bigint", nullable: true, comment: "创建人id"), create_by_name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "创建人名称"), create_time = table.Column(type: "datetime2", nullable: true, comment: "创建时间"), factory_id = table.Column(type: "bigint", nullable: true, comment: "工厂ID"), icitem_stock_id = table.Column(type: "bigint", nullable: false, comment: "物料库存主键"), kf_date = table.Column(type: "datetime2", nullable: true, comment: "保质期时间"), kf_period = table.Column(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "保质期时长"), org_id = table.Column(type: "bigint", nullable: true, comment: "组织ID"), qty = table.Column(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "数量"), qty_lock = table.Column(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "锁定库存"), rq = table.Column(type: "datetime2", nullable: true, comment: "日期"), sec_qty = table.Column(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "安全库存"), stock_id = table.Column(type: "bigint", nullable: false, comment: "仓库id"), stock_name = table.Column(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "仓库名称"), stock_place_code = table.Column(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "库位编码"), stock_place_id = table.Column(type: "bigint", nullable: false, comment: "库位id"), tenant_id = table.Column(type: "bigint", nullable: false, comment: "企业ID"), unit = table.Column(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "单位"), update_by = table.Column(type: "bigint", nullable: true, comment: "修改人"), update_by_name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "修改人名称"), update_time = table.Column(type: "datetime2", nullable: true, comment: "修改时间") }, constraints: table => { table.PrimaryKey("PK_ic_item_inventory", x => x.Id); }, comment: "物料库存明细表"); migrationBuilder.CreateIndex( name: "IX_srm_supplier_supplier_no_tenant_id_factory_id", table: "srm_supplier", columns: new[] { "supplier_no", "tenant_id", "factory_id" }); migrationBuilder.CreateIndex( name: "IX_srm_po_main_po_billno_tenant_id_factory_id", table: "srm_po_main", columns: new[] { "po_billno", "tenant_id", "factory_id" }); migrationBuilder.CreateIndex( name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id", table: "ic_bom", columns: new[] { "bom_number", "item_number", "version", "tenant_id", "factory_id" }); migrationBuilder.CreateIndex( name: "IX_crm_seorder_bill_no_tenant_id_factory_id", table: "crm_seorder", columns: new[] { "bill_no", "tenant_id", "factory_id" }); migrationBuilder.CreateIndex( name: "IX_crm_customer_customer_no_tenant_id_factory_id", table: "crm_customer", columns: new[] { "customer_no", "tenant_id", "factory_id" }); migrationBuilder.CreateIndex( name: "IX_ic_item_inventory_stock_id_stock_place_id_tenant_id_factory_id", table: "ic_item_inventory", columns: new[] { "stock_id", "stock_place_id", "tenant_id", "factory_id" }); } } }