20211125055834_EditBDM.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace Ropin.Inspection.Model.Migrations
  4. {
  5. public partial class EditBDM : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "TBDM_CodeDetail",
  11. columns: table => new
  12. {
  13. C_Code = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  14. C_MainCode = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  15. C_Name = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  16. C_Value = table.Column<string>(type: "varchar(255) CHARACTER SET utf8mb4", maxLength: 255, nullable: false),
  17. C_IsSys = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", maxLength: 1, nullable: false),
  18. C_Default = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", maxLength: 1, nullable: false),
  19. I_Sort = table.Column<int>(type: "int", nullable: false),
  20. C_Remark = table.Column<string>(type: "varchar(500) CHARACTER SET utf8mb4", maxLength: 500, nullable: true),
  21. C_CreateBy = table.Column<Guid>(type: "char(36)", nullable: false),
  22. D_CreateOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
  23. C_LastUpdatedBy = table.Column<Guid>(type: "char(36)", nullable: true),
  24. D_LastUpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: true),
  25. C_Status = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false)
  26. },
  27. constraints: table =>
  28. {
  29. table.PrimaryKey("PK_TBDM_CodeDetail", x => x.C_Code);
  30. table.ForeignKey(
  31. name: "FK_TBDM_CodeDetail_TSYS_User_C_CreateBy",
  32. column: x => x.C_CreateBy,
  33. principalTable: "TSYS_User",
  34. principalColumn: "C_UserID",
  35. onDelete: ReferentialAction.Restrict);
  36. table.ForeignKey(
  37. name: "FK_TBDM_CodeDetail_TSYS_User_C_LastUpdatedBy",
  38. column: x => x.C_LastUpdatedBy,
  39. principalTable: "TSYS_User",
  40. principalColumn: "C_UserID",
  41. onDelete: ReferentialAction.Restrict);
  42. });
  43. migrationBuilder.CreateTable(
  44. name: "TBDM_CodeMain",
  45. columns: table => new
  46. {
  47. C_Code = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  48. C_Name = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  49. I_Sort = table.Column<int>(type: "int", nullable: false),
  50. C_Remark = table.Column<string>(type: "varchar(500) CHARACTER SET utf8mb4", maxLength: 500, nullable: true),
  51. C_CreateBy = table.Column<Guid>(type: "char(36)", nullable: false),
  52. D_CreateOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
  53. C_LastUpdatedBy = table.Column<Guid>(type: "char(36)", nullable: true),
  54. D_LastUpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: true),
  55. C_Status = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false)
  56. },
  57. constraints: table =>
  58. {
  59. table.PrimaryKey("PK_TBDM_CodeMain", x => x.C_Code);
  60. table.ForeignKey(
  61. name: "FK_TBDM_CodeMain_TSYS_User_C_CreateBy",
  62. column: x => x.C_CreateBy,
  63. principalTable: "TSYS_User",
  64. principalColumn: "C_UserID",
  65. onDelete: ReferentialAction.Restrict);
  66. table.ForeignKey(
  67. name: "FK_TBDM_CodeMain_TSYS_User_C_LastUpdatedBy",
  68. column: x => x.C_LastUpdatedBy,
  69. principalTable: "TSYS_User",
  70. principalColumn: "C_UserID",
  71. onDelete: ReferentialAction.Restrict);
  72. });
  73. migrationBuilder.CreateTable(
  74. name: "TBDM_Prov",
  75. columns: table => new
  76. {
  77. C_Code = table.Column<string>(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false),
  78. C_Name = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  79. I_Sort = table.Column<int>(type: "int", nullable: false),
  80. C_Status = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false)
  81. },
  82. constraints: table =>
  83. {
  84. table.PrimaryKey("PK_TBDM_Prov", x => x.C_Code);
  85. });
  86. migrationBuilder.CreateTable(
  87. name: "TBDM_City",
  88. columns: table => new
  89. {
  90. C_Code = table.Column<string>(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false),
  91. C_ProvCode = table.Column<string>(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false),
  92. C_Name = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  93. I_Sort = table.Column<int>(type: "int", nullable: false),
  94. C_Status = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false)
  95. },
  96. constraints: table =>
  97. {
  98. table.PrimaryKey("PK_TBDM_City", x => x.C_Code);
  99. table.ForeignKey(
  100. name: "FK_TBDM_City_TBDM_Prov_C_ProvCode",
  101. column: x => x.C_ProvCode,
  102. principalTable: "TBDM_Prov",
  103. principalColumn: "C_Code",
  104. onDelete: ReferentialAction.Restrict);
  105. });
  106. migrationBuilder.CreateTable(
  107. name: "TBDM_Area",
  108. columns: table => new
  109. {
  110. C_Code = table.Column<string>(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false),
  111. C_CityCode = table.Column<string>(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false),
  112. C_Name = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  113. I_Sort = table.Column<int>(type: "int", nullable: false),
  114. C_Status = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false)
  115. },
  116. constraints: table =>
  117. {
  118. table.PrimaryKey("PK_TBDM_Area", x => x.C_Code);
  119. table.ForeignKey(
  120. name: "FK_TBDM_Area_TBDM_City_C_CityCode",
  121. column: x => x.C_CityCode,
  122. principalTable: "TBDM_City",
  123. principalColumn: "C_Code",
  124. onDelete: ReferentialAction.Restrict);
  125. });
  126. migrationBuilder.CreateIndex(
  127. name: "IX_TBDM_Area_C_CityCode",
  128. table: "TBDM_Area",
  129. column: "C_CityCode");
  130. migrationBuilder.CreateIndex(
  131. name: "IX_TBDM_City_C_ProvCode",
  132. table: "TBDM_City",
  133. column: "C_ProvCode");
  134. migrationBuilder.CreateIndex(
  135. name: "IX_TBDM_CodeDetail_C_CreateBy",
  136. table: "TBDM_CodeDetail",
  137. column: "C_CreateBy");
  138. migrationBuilder.CreateIndex(
  139. name: "IX_TBDM_CodeDetail_C_LastUpdatedBy",
  140. table: "TBDM_CodeDetail",
  141. column: "C_LastUpdatedBy");
  142. migrationBuilder.CreateIndex(
  143. name: "IX_TBDM_CodeMain_C_CreateBy",
  144. table: "TBDM_CodeMain",
  145. column: "C_CreateBy");
  146. migrationBuilder.CreateIndex(
  147. name: "IX_TBDM_CodeMain_C_LastUpdatedBy",
  148. table: "TBDM_CodeMain",
  149. column: "C_LastUpdatedBy");
  150. }
  151. protected override void Down(MigrationBuilder migrationBuilder)
  152. {
  153. migrationBuilder.DropTable(
  154. name: "TBDM_Area");
  155. migrationBuilder.DropTable(
  156. name: "TBDM_CodeDetail");
  157. migrationBuilder.DropTable(
  158. name: "TBDM_CodeMain");
  159. migrationBuilder.DropTable(
  160. name: "TBDM_City");
  161. migrationBuilder.DropTable(
  162. name: "TBDM_Prov");
  163. }
  164. }
  165. }