20211125085144_EdDev.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace Ropin.Inspection.Model.Migrations
  4. {
  5. public partial class EdDev : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "TDEV_DevAlert",
  11. columns: table => new
  12. {
  13. C_ID = table.Column<Guid>(type: "char(36)", nullable: false),
  14. C_DeviceCode = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  15. C_ConfigCode = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  16. C_Value = table.Column<string>(type: "varchar(100) CHARACTER SET utf8mb4", maxLength: 100, nullable: false),
  17. D_CreateOn = table.Column<DateTime>(type: "datetime(6)", nullable: false)
  18. },
  19. constraints: table =>
  20. {
  21. table.PrimaryKey("PK_TDEV_DevAlert", x => x.C_ID);
  22. });
  23. migrationBuilder.CreateTable(
  24. name: "TDEV_DevAlertConfig",
  25. columns: table => new
  26. {
  27. C_Code = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  28. C_Name = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  29. C_Remark = table.Column<string>(type: "varchar(1024) CHARACTER SET utf8mb4", maxLength: 1024, nullable: true),
  30. C_CreateBy = table.Column<Guid>(type: "char(36)", nullable: false),
  31. D_CreateOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
  32. C_LastUpdatedBy = table.Column<Guid>(type: "char(36)", nullable: true),
  33. D_LastUpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: true),
  34. C_Status = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false)
  35. },
  36. constraints: table =>
  37. {
  38. table.PrimaryKey("PK_TDEV_DevAlertConfig", x => x.C_Code);
  39. table.ForeignKey(
  40. name: "FK_TDEV_DevAlertConfig_TSYS_User_C_CreateBy",
  41. column: x => x.C_CreateBy,
  42. principalTable: "TSYS_User",
  43. principalColumn: "C_UserID",
  44. onDelete: ReferentialAction.Restrict);
  45. table.ForeignKey(
  46. name: "FK_TDEV_DevAlertConfig_TSYS_User_C_LastUpdatedBy",
  47. column: x => x.C_LastUpdatedBy,
  48. principalTable: "TSYS_User",
  49. principalColumn: "C_UserID",
  50. onDelete: ReferentialAction.Restrict);
  51. });
  52. migrationBuilder.CreateTable(
  53. name: "TDEV_DevData",
  54. columns: table => new
  55. {
  56. C_ID = table.Column<Guid>(type: "char(36)", nullable: false),
  57. C_DeviceCode = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  58. C_ConfigCode = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  59. C_Value = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  60. D_CreateOn = table.Column<DateTime>(type: "datetime(6)", nullable: false)
  61. },
  62. constraints: table =>
  63. {
  64. table.PrimaryKey("PK_TDEV_DevData", x => x.C_ID);
  65. });
  66. migrationBuilder.CreateTable(
  67. name: "TDEV_DevDataConfig",
  68. columns: table => new
  69. {
  70. C_Code = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  71. C_Name = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  72. I_Interval = table.Column<int>(type: "int", nullable: false),
  73. C_Remark = table.Column<string>(type: "varchar(1024) CHARACTER SET utf8mb4", maxLength: 1024, nullable: true),
  74. C_CreateBy = table.Column<Guid>(type: "char(36)", nullable: false),
  75. D_CreateOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
  76. C_LastUpdatedBy = table.Column<Guid>(type: "char(36)", nullable: true),
  77. D_LastUpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: true),
  78. C_Status = table.Column<string>(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false)
  79. },
  80. constraints: table =>
  81. {
  82. table.PrimaryKey("PK_TDEV_DevDataConfig", x => x.C_Code);
  83. table.ForeignKey(
  84. name: "FK_TDEV_DevDataConfig_TSYS_User_C_CreateBy",
  85. column: x => x.C_CreateBy,
  86. principalTable: "TSYS_User",
  87. principalColumn: "C_UserID",
  88. onDelete: ReferentialAction.Restrict);
  89. table.ForeignKey(
  90. name: "FK_TDEV_DevDataConfig_TSYS_User_C_LastUpdatedBy",
  91. column: x => x.C_LastUpdatedBy,
  92. principalTable: "TSYS_User",
  93. principalColumn: "C_UserID",
  94. onDelete: ReferentialAction.Restrict);
  95. });
  96. migrationBuilder.CreateTable(
  97. name: "TDEV_Device",
  98. columns: table => new
  99. {
  100. C_Code = table.Column<Guid>(type: "char(36)", nullable: false),
  101. C_ProductCode = table.Column<string>(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false),
  102. C_MachineCode = table.Column<string>(type: "varchar(255) CHARACTER SET utf8mb4", maxLength: 255, nullable: true),
  103. C_Remark = table.Column<string>(type: "varchar(1024) CHARACTER SET utf8mb4", maxLength: 1024, nullable: true),
  104. C_CreateBy = table.Column<Guid>(type: "char(36)", nullable: false),
  105. D_CreateOn = table.Column<DateTime>(type: "datetime(6)", nullable: false),
  106. C_LastUpdatedBy = table.Column<Guid>(type: "char(36)", nullable: true),
  107. D_LastUpdatedOn = table.Column<DateTime>(type: "datetime(6)", nullable: true),
  108. I_Status = table.Column<int>(type: "int", nullable: false)
  109. },
  110. constraints: table =>
  111. {
  112. table.PrimaryKey("PK_TDEV_Device", x => x.C_Code);
  113. table.ForeignKey(
  114. name: "FK_TDEV_Device_TSYS_User_C_CreateBy",
  115. column: x => x.C_CreateBy,
  116. principalTable: "TSYS_User",
  117. principalColumn: "C_UserID",
  118. onDelete: ReferentialAction.Restrict);
  119. table.ForeignKey(
  120. name: "FK_TDEV_Device_TSYS_User_C_LastUpdatedBy",
  121. column: x => x.C_LastUpdatedBy,
  122. principalTable: "TSYS_User",
  123. principalColumn: "C_UserID",
  124. onDelete: ReferentialAction.Restrict);
  125. });
  126. migrationBuilder.CreateIndex(
  127. name: "IX_TDEV_DevAlertConfig_C_CreateBy",
  128. table: "TDEV_DevAlertConfig",
  129. column: "C_CreateBy");
  130. migrationBuilder.CreateIndex(
  131. name: "IX_TDEV_DevAlertConfig_C_LastUpdatedBy",
  132. table: "TDEV_DevAlertConfig",
  133. column: "C_LastUpdatedBy");
  134. migrationBuilder.CreateIndex(
  135. name: "IX_TDEV_DevDataConfig_C_CreateBy",
  136. table: "TDEV_DevDataConfig",
  137. column: "C_CreateBy");
  138. migrationBuilder.CreateIndex(
  139. name: "IX_TDEV_DevDataConfig_C_LastUpdatedBy",
  140. table: "TDEV_DevDataConfig",
  141. column: "C_LastUpdatedBy");
  142. migrationBuilder.CreateIndex(
  143. name: "IX_TDEV_Device_C_CreateBy",
  144. table: "TDEV_Device",
  145. column: "C_CreateBy");
  146. migrationBuilder.CreateIndex(
  147. name: "IX_TDEV_Device_C_LastUpdatedBy",
  148. table: "TDEV_Device",
  149. column: "C_LastUpdatedBy");
  150. }
  151. protected override void Down(MigrationBuilder migrationBuilder)
  152. {
  153. migrationBuilder.DropTable(
  154. name: "TDEV_DevAlert");
  155. migrationBuilder.DropTable(
  156. name: "TDEV_DevAlertConfig");
  157. migrationBuilder.DropTable(
  158. name: "TDEV_DevData");
  159. migrationBuilder.DropTable(
  160. name: "TDEV_DevDataConfig");
  161. migrationBuilder.DropTable(
  162. name: "TDEV_Device");
  163. }
  164. }
  165. }