20230619062335_AddIndex.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. #nullable disable
  4. namespace Business.Migrations
  5. {
  6. public partial class AddIndex : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.DropTable(
  11. name: "ic_item_inventory");
  12. migrationBuilder.DropIndex(
  13. name: "IX_srm_supplier_supplier_no_tenant_id_factory_id",
  14. table: "srm_supplier");
  15. migrationBuilder.DropIndex(
  16. name: "IX_srm_po_main_po_billno_tenant_id_factory_id",
  17. table: "srm_po_main");
  18. migrationBuilder.DropIndex(
  19. name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id",
  20. table: "ic_bom");
  21. migrationBuilder.DropIndex(
  22. name: "IX_crm_seorder_bill_no_tenant_id_factory_id",
  23. table: "crm_seorder");
  24. migrationBuilder.DropIndex(
  25. name: "IX_crm_customer_customer_no_tenant_id_factory_id",
  26. table: "crm_customer");
  27. migrationBuilder.DropColumn(
  28. name: "factory_fode",
  29. table: "ic_item_stock");
  30. migrationBuilder.AddColumn<string>(
  31. name: "number",
  32. table: "srm_purchase",
  33. type: "nvarchar(20)",
  34. maxLength: 20,
  35. nullable: true,
  36. comment: "物料编码");
  37. migrationBuilder.AddColumn<string>(
  38. name: "fversion",
  39. table: "ic_substitute_group_detail",
  40. type: "nvarchar(80)",
  41. maxLength: 80,
  42. nullable: true,
  43. comment: "版本号");
  44. migrationBuilder.AddColumn<string>(
  45. name: "fversion",
  46. table: "ic_item_stock",
  47. type: "nvarchar(80)",
  48. maxLength: 80,
  49. nullable: true,
  50. comment: "版本号");
  51. migrationBuilder.AddColumn<string>(
  52. name: "icitem_number",
  53. table: "ic_item_stock",
  54. type: "nvarchar(80)",
  55. maxLength: 80,
  56. nullable: true,
  57. comment: "物料编码");
  58. migrationBuilder.CreateIndex(
  59. name: "IX_srm_supplier_supplier_no_tenant_id_factory_id",
  60. table: "srm_supplier",
  61. columns: new[] { "supplier_no", "tenant_id", "factory_id" },
  62. unique: true,
  63. filter: "[supplier_no] IS NOT NULL AND [factory_id] IS NOT NULL");
  64. migrationBuilder.CreateIndex(
  65. name: "IX_srm_purchase_supplier_number_number_tenant_id_factory_id",
  66. table: "srm_purchase",
  67. columns: new[] { "supplier_number", "number", "tenant_id", "factory_id" },
  68. unique: true,
  69. filter: "[supplier_number] IS NOT NULL AND [number] IS NOT NULL AND [factory_id] IS NOT NULL");
  70. migrationBuilder.CreateIndex(
  71. name: "IX_srm_pr_main_pr_billno_tenant_id_factory_id",
  72. table: "srm_pr_main",
  73. columns: new[] { "pr_billno", "tenant_id", "factory_id" },
  74. unique: true,
  75. filter: "[pr_billno] IS NOT NULL AND [factory_id] IS NOT NULL");
  76. migrationBuilder.CreateIndex(
  77. name: "IX_srm_po_main_po_billno_tenant_id_factory_id",
  78. table: "srm_po_main",
  79. columns: new[] { "po_billno", "tenant_id", "factory_id" },
  80. unique: true,
  81. filter: "[po_billno] IS NOT NULL AND [factory_id] IS NOT NULL");
  82. migrationBuilder.CreateIndex(
  83. name: "IX_srm_po_list_po_billno_polist_row_tenant_id_factory_id",
  84. table: "srm_po_list",
  85. columns: new[] { "po_billno", "polist_row", "tenant_id", "factory_id" },
  86. unique: true,
  87. filter: "[po_billno] IS NOT NULL AND [polist_row] IS NOT NULL AND [factory_id] IS NOT NULL");
  88. migrationBuilder.CreateIndex(
  89. name: "IX_ic_item_stock_icitem_number_fversion_tenant_id_factory_id",
  90. table: "ic_item_stock",
  91. columns: new[] { "icitem_number", "fversion", "tenant_id", "factory_id" },
  92. unique: true,
  93. filter: "[icitem_number] IS NOT NULL AND [fversion] IS NOT NULL AND [factory_id] IS NOT NULL");
  94. migrationBuilder.CreateIndex(
  95. name: "IX_ic_item_number_fversion_tenant_id_factory_id",
  96. table: "ic_item",
  97. columns: new[] { "number", "fversion", "tenant_id", "factory_id" },
  98. unique: true,
  99. filter: "[number] IS NOT NULL AND [fversion] IS NOT NULL AND [factory_id] IS NOT NULL");
  100. migrationBuilder.CreateIndex(
  101. name: "IX_ic_bom_child_bom_number_item_number_version_tenant_id_factory_id",
  102. table: "ic_bom_child",
  103. columns: new[] { "bom_number", "item_number", "version", "tenant_id", "factory_id" },
  104. unique: true,
  105. filter: "[bom_number] IS NOT NULL AND [item_number] IS NOT NULL AND [version] IS NOT NULL AND [factory_id] IS NOT NULL");
  106. migrationBuilder.CreateIndex(
  107. name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id",
  108. table: "ic_bom",
  109. columns: new[] { "bom_number", "item_number", "version", "tenant_id", "factory_id" },
  110. unique: true,
  111. filter: "[bom_number] IS NOT NULL AND [item_number] IS NOT NULL AND [version] IS NOT NULL AND [factory_id] IS NOT NULL");
  112. migrationBuilder.CreateIndex(
  113. name: "IX_crm_seorderentry_bill_no_entry_seq_tenant_id_factory_id",
  114. table: "crm_seorderentry",
  115. columns: new[] { "bill_no", "entry_seq", "tenant_id", "factory_id" },
  116. unique: true,
  117. filter: "[bill_no] IS NOT NULL AND [entry_seq] IS NOT NULL AND [factory_id] IS NOT NULL");
  118. migrationBuilder.CreateIndex(
  119. name: "IX_crm_seorder_bill_no_tenant_id_factory_id",
  120. table: "crm_seorder",
  121. columns: new[] { "bill_no", "tenant_id", "factory_id" },
  122. unique: true,
  123. filter: "[bill_no] IS NOT NULL AND [factory_id] IS NOT NULL");
  124. migrationBuilder.CreateIndex(
  125. name: "IX_crm_customer_customer_no_tenant_id_factory_id",
  126. table: "crm_customer",
  127. columns: new[] { "customer_no", "tenant_id", "factory_id" },
  128. unique: true,
  129. filter: "[customer_no] IS NOT NULL AND [factory_id] IS NOT NULL");
  130. }
  131. protected override void Down(MigrationBuilder migrationBuilder)
  132. {
  133. migrationBuilder.DropIndex(
  134. name: "IX_srm_supplier_supplier_no_tenant_id_factory_id",
  135. table: "srm_supplier");
  136. migrationBuilder.DropIndex(
  137. name: "IX_srm_purchase_sourcelist_number_icitem_number_tenant_id_factory_id",
  138. table: "srm_purchase");
  139. migrationBuilder.DropIndex(
  140. name: "IX_srm_pr_main_pr_billno_tenant_id_factory_id",
  141. table: "srm_pr_main");
  142. migrationBuilder.DropIndex(
  143. name: "IX_srm_po_main_po_billno_tenant_id_factory_id",
  144. table: "srm_po_main");
  145. migrationBuilder.DropIndex(
  146. name: "IX_srm_po_list_po_billno_polist_row_tenant_id_factory_id",
  147. table: "srm_po_list");
  148. migrationBuilder.DropIndex(
  149. name: "IX_ic_item_stock_icitem_number_fversion_tenant_id_factory_id",
  150. table: "ic_item_stock");
  151. migrationBuilder.DropIndex(
  152. name: "IX_ic_item_number_fversion_tenant_id_factory_id",
  153. table: "ic_item");
  154. migrationBuilder.DropIndex(
  155. name: "IX_ic_bom_child_bom_number_item_number_version_tenant_id_factory_id",
  156. table: "ic_bom_child");
  157. migrationBuilder.DropIndex(
  158. name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id",
  159. table: "ic_bom");
  160. migrationBuilder.DropIndex(
  161. name: "IX_crm_seorderentry_bill_no_entry_seq_tenant_id_factory_id",
  162. table: "crm_seorderentry");
  163. migrationBuilder.DropIndex(
  164. name: "IX_crm_seorder_bill_no_tenant_id_factory_id",
  165. table: "crm_seorder");
  166. migrationBuilder.DropIndex(
  167. name: "IX_crm_customer_customer_no_tenant_id_factory_id",
  168. table: "crm_customer");
  169. migrationBuilder.DropColumn(
  170. name: "icitem_number",
  171. table: "srm_purchase");
  172. migrationBuilder.DropColumn(
  173. name: "fversion",
  174. table: "ic_substitute_group_detail");
  175. migrationBuilder.DropColumn(
  176. name: "fversion",
  177. table: "ic_item_stock");
  178. migrationBuilder.DropColumn(
  179. name: "icitem_number",
  180. table: "ic_item_stock");
  181. migrationBuilder.AddColumn<string>(
  182. name: "factory_fode",
  183. table: "ic_item_stock",
  184. type: "nvarchar(80)",
  185. maxLength: 80,
  186. nullable: true,
  187. comment: "工厂编码");
  188. migrationBuilder.CreateTable(
  189. name: "ic_item_inventory",
  190. columns: table => new
  191. {
  192. Id = table.Column<long>(type: "bigint", nullable: false),
  193. IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false, comment: "删除标识"),
  194. bal = table.Column<decimal>(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "金额"),
  195. batch_no = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "批次号"),
  196. create_by = table.Column<long>(type: "bigint", nullable: true, comment: "创建人id"),
  197. create_by_name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "创建人名称"),
  198. create_time = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "创建时间"),
  199. factory_id = table.Column<long>(type: "bigint", nullable: true, comment: "工厂ID"),
  200. icitem_stock_id = table.Column<long>(type: "bigint", nullable: false, comment: "物料库存主键"),
  201. kf_date = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "保质期时间"),
  202. kf_period = table.Column<decimal>(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "保质期时长"),
  203. org_id = table.Column<long>(type: "bigint", nullable: true, comment: "组织ID"),
  204. qty = table.Column<decimal>(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "数量"),
  205. qty_lock = table.Column<decimal>(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "锁定库存"),
  206. rq = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "日期"),
  207. sec_qty = table.Column<decimal>(type: "decimal(23,10)", precision: 23, scale: 10, nullable: true, comment: "安全库存"),
  208. stock_id = table.Column<long>(type: "bigint", nullable: false, comment: "仓库id"),
  209. stock_name = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "仓库名称"),
  210. stock_place_code = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "库位编码"),
  211. stock_place_id = table.Column<long>(type: "bigint", nullable: false, comment: "库位id"),
  212. tenant_id = table.Column<long>(type: "bigint", nullable: false, comment: "企业ID"),
  213. unit = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: true, comment: "单位"),
  214. update_by = table.Column<long>(type: "bigint", nullable: true, comment: "修改人"),
  215. update_by_name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true, comment: "修改人名称"),
  216. update_time = table.Column<DateTime>(type: "datetime2", nullable: true, comment: "修改时间")
  217. },
  218. constraints: table =>
  219. {
  220. table.PrimaryKey("PK_ic_item_inventory", x => x.Id);
  221. },
  222. comment: "物料库存明细表");
  223. migrationBuilder.CreateIndex(
  224. name: "IX_srm_supplier_supplier_no_tenant_id_factory_id",
  225. table: "srm_supplier",
  226. columns: new[] { "supplier_no", "tenant_id", "factory_id" });
  227. migrationBuilder.CreateIndex(
  228. name: "IX_srm_po_main_po_billno_tenant_id_factory_id",
  229. table: "srm_po_main",
  230. columns: new[] { "po_billno", "tenant_id", "factory_id" });
  231. migrationBuilder.CreateIndex(
  232. name: "IX_ic_bom_bom_number_item_number_version_tenant_id_factory_id",
  233. table: "ic_bom",
  234. columns: new[] { "bom_number", "item_number", "version", "tenant_id", "factory_id" });
  235. migrationBuilder.CreateIndex(
  236. name: "IX_crm_seorder_bill_no_tenant_id_factory_id",
  237. table: "crm_seorder",
  238. columns: new[] { "bill_no", "tenant_id", "factory_id" });
  239. migrationBuilder.CreateIndex(
  240. name: "IX_crm_customer_customer_no_tenant_id_factory_id",
  241. table: "crm_customer",
  242. columns: new[] { "customer_no", "tenant_id", "factory_id" });
  243. migrationBuilder.CreateIndex(
  244. name: "IX_ic_item_inventory_stock_id_stock_place_id_tenant_id_factory_id",
  245. table: "ic_item_inventory",
  246. columns: new[] { "stock_id", "stock_place_id", "tenant_id", "factory_id" });
  247. }
  248. }
  249. }