20200522082859_init.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace Application.ATG_Classic_App.Migrations
  4. {
  5. public partial class init : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "Alarms",
  11. columns: table => new
  12. {
  13. Id = table.Column<int>(nullable: false)
  14. .Annotation("Sqlite:Autoincrement", true),
  15. Priority = table.Column<int>(nullable: false),
  16. TankNumber = table.Column<byte>(nullable: false),
  17. Type = table.Column<int>(nullable: false),
  18. Description = table.Column<string>(nullable: true),
  19. CreatedTimeStamp = table.Column<DateTime>(nullable: false),
  20. ClearedTimeStamp = table.Column<DateTime>(nullable: true)
  21. },
  22. constraints: table =>
  23. {
  24. table.PrimaryKey("PK_Alarms", x => x.Id);
  25. });
  26. migrationBuilder.CreateTable(
  27. name: "Deliveries",
  28. columns: table => new
  29. {
  30. Id = table.Column<int>(nullable: false)
  31. .Annotation("Sqlite:Autoincrement", true),
  32. TankNumber = table.Column<byte>(nullable: false),
  33. StartingDateTime = table.Column<DateTime>(nullable: false),
  34. StartingFuelHeight = table.Column<double>(nullable: false),
  35. StartingFuelVolume = table.Column<double>(nullable: false),
  36. StartingFuelTCVolume = table.Column<double>(nullable: false),
  37. StartingWaterHeight = table.Column<double>(nullable: false),
  38. StartingWaterVolume = table.Column<double>(nullable: false),
  39. StartingTemperture = table.Column<double>(nullable: false),
  40. EndingDateTime = table.Column<DateTime>(nullable: true),
  41. EndingFuelHeight = table.Column<double>(nullable: true),
  42. EndingFuelVolume = table.Column<double>(nullable: true),
  43. EndingFuelTCVolume = table.Column<double>(nullable: true),
  44. EndingWaterHeight = table.Column<double>(nullable: true),
  45. EndingWaterVolume = table.Column<double>(nullable: true),
  46. EndingTemperture = table.Column<double>(nullable: true),
  47. Description = table.Column<string>(nullable: true)
  48. },
  49. constraints: table =>
  50. {
  51. table.PrimaryKey("PK_Deliveries", x => x.Id);
  52. });
  53. migrationBuilder.CreateTable(
  54. name: "Inventories",
  55. columns: table => new
  56. {
  57. Id = table.Column<int>(nullable: false)
  58. .Annotation("Sqlite:Autoincrement", true),
  59. TankNumber = table.Column<int>(nullable: false),
  60. TimeStamp = table.Column<DateTime>(nullable: false),
  61. FuelHeight = table.Column<double>(nullable: false),
  62. FuelVolume = table.Column<double>(nullable: false),
  63. FuelTCVolume = table.Column<double>(nullable: false),
  64. WaterHeight = table.Column<double>(nullable: false),
  65. Temperture = table.Column<double>(nullable: false),
  66. Description = table.Column<string>(nullable: true)
  67. },
  68. constraints: table =>
  69. {
  70. table.PrimaryKey("PK_Inventories", x => x.Id);
  71. });
  72. migrationBuilder.CreateTable(
  73. name: "ProbeConfigs",
  74. columns: table => new
  75. {
  76. Id = table.Column<int>(nullable: false)
  77. .Annotation("Sqlite:Autoincrement", true),
  78. CreatedTimeStamp = table.Column<DateTime>(nullable: false),
  79. ModifiedTimeStamp = table.Column<DateTime>(nullable: true),
  80. DeviceId = table.Column<int>(nullable: false),
  81. ProbeOffset = table.Column<double>(nullable: false),
  82. WaterOffset = table.Column<double>(nullable: false)
  83. },
  84. constraints: table =>
  85. {
  86. table.PrimaryKey("PK_ProbeConfigs", x => x.Id);
  87. });
  88. migrationBuilder.CreateTable(
  89. name: "ProductConfigs",
  90. columns: table => new
  91. {
  92. Id = table.Column<int>(nullable: false)
  93. .Annotation("Sqlite:Autoincrement", true),
  94. CreatedTimeStamp = table.Column<DateTime>(nullable: false),
  95. ModifiedTimeStamp = table.Column<DateTime>(nullable: true),
  96. ProductCode = table.Column<string>(nullable: false),
  97. ProductLabel = table.Column<string>(nullable: true)
  98. },
  99. constraints: table =>
  100. {
  101. table.PrimaryKey("PK_ProductConfigs", x => x.Id);
  102. });
  103. migrationBuilder.CreateTable(
  104. name: "TankLimitConfigs",
  105. columns: table => new
  106. {
  107. Id = table.Column<int>(nullable: false)
  108. .Annotation("Sqlite:Autoincrement", true),
  109. CreatedTimeStamp = table.Column<DateTime>(nullable: false),
  110. ModifiedTimeStamp = table.Column<DateTime>(nullable: true),
  111. MaxVolume = table.Column<double>(nullable: false),
  112. FullVolume = table.Column<double>(nullable: false),
  113. HighProduct = table.Column<double>(nullable: false),
  114. LowProduct = table.Column<double>(nullable: false),
  115. HighWaterWarning = table.Column<double>(nullable: false),
  116. HighWaterAlarm = table.Column<double>(nullable: false),
  117. FuelTemperatureLowLimit = table.Column<double>(nullable: false),
  118. FuelTemperatureHighLimit = table.Column<double>(nullable: false)
  119. },
  120. constraints: table =>
  121. {
  122. table.PrimaryKey("PK_TankLimitConfigs", x => x.Id);
  123. });
  124. migrationBuilder.CreateTable(
  125. name: "TankOverallConfigs",
  126. columns: table => new
  127. {
  128. Id = table.Column<int>(nullable: false)
  129. .Annotation("Sqlite:Autoincrement", true),
  130. CreatedTimeStamp = table.Column<DateTime>(nullable: false),
  131. ModifiedTimeStamp = table.Column<DateTime>(nullable: true),
  132. TcReference = table.Column<double>(nullable: false),
  133. InventorySamplingInterval = table.Column<int>(nullable: false),
  134. DeliveryMode = table.Column<int>(nullable: false)
  135. },
  136. constraints: table =>
  137. {
  138. table.PrimaryKey("PK_TankOverallConfigs", x => x.Id);
  139. });
  140. migrationBuilder.CreateTable(
  141. name: "TankConfigs",
  142. columns: table => new
  143. {
  144. Id = table.Column<int>(nullable: false)
  145. .Annotation("Sqlite:Autoincrement", true),
  146. CreatedTimeStamp = table.Column<DateTime>(nullable: false),
  147. ModifiedTimeStamp = table.Column<DateTime>(nullable: true),
  148. TankNumber = table.Column<byte>(nullable: false),
  149. Label = table.Column<string>(nullable: true),
  150. Diameter = table.Column<double>(nullable: false),
  151. ThermalCoefficient = table.Column<double>(nullable: false),
  152. DeliveryDelay = table.Column<int>(nullable: false),
  153. ProductConfigId = table.Column<int>(nullable: true),
  154. TankLimitConfigId = table.Column<int>(nullable: true),
  155. ProbeConfigId = table.Column<int>(nullable: true)
  156. },
  157. constraints: table =>
  158. {
  159. table.PrimaryKey("PK_TankConfigs", x => x.Id);
  160. table.ForeignKey(
  161. name: "FK_TankConfigs_ProbeConfigs_ProbeConfigId",
  162. column: x => x.ProbeConfigId,
  163. principalTable: "ProbeConfigs",
  164. principalColumn: "Id",
  165. onDelete: ReferentialAction.Restrict);
  166. table.ForeignKey(
  167. name: "FK_TankConfigs_ProductConfigs_ProductConfigId",
  168. column: x => x.ProductConfigId,
  169. principalTable: "ProductConfigs",
  170. principalColumn: "Id",
  171. onDelete: ReferentialAction.Restrict);
  172. table.ForeignKey(
  173. name: "FK_TankConfigs_TankLimitConfigs_TankLimitConfigId",
  174. column: x => x.TankLimitConfigId,
  175. principalTable: "TankLimitConfigs",
  176. principalColumn: "Id",
  177. onDelete: ReferentialAction.Restrict);
  178. });
  179. migrationBuilder.CreateTable(
  180. name: "TankProfileDatas",
  181. columns: table => new
  182. {
  183. Id = table.Column<int>(nullable: false)
  184. .Annotation("Sqlite:Autoincrement", true),
  185. BatchLabel = table.Column<string>(nullable: true),
  186. TankConfigId = table.Column<int>(nullable: false),
  187. Height = table.Column<double>(nullable: false),
  188. Volume = table.Column<double>(nullable: false),
  189. VolumeChange = table.Column<double>(nullable: true)
  190. },
  191. constraints: table =>
  192. {
  193. table.PrimaryKey("PK_TankProfileDatas", x => x.Id);
  194. table.ForeignKey(
  195. name: "FK_TankProfileDatas_TankConfigs_TankConfigId",
  196. column: x => x.TankConfigId,
  197. principalTable: "TankConfigs",
  198. principalColumn: "Id",
  199. onDelete: ReferentialAction.Cascade);
  200. });
  201. migrationBuilder.CreateIndex(
  202. name: "IX_Alarms_CreatedTimeStamp",
  203. table: "Alarms",
  204. column: "CreatedTimeStamp");
  205. migrationBuilder.CreateIndex(
  206. name: "IX_Alarms_TankNumber",
  207. table: "Alarms",
  208. column: "TankNumber");
  209. migrationBuilder.CreateIndex(
  210. name: "IX_Alarms_TankNumber_Type_Priority_ClearedTimeStamp",
  211. table: "Alarms",
  212. columns: new[] { "TankNumber", "Type", "Priority", "ClearedTimeStamp" },
  213. unique: true);
  214. migrationBuilder.CreateIndex(
  215. name: "IX_Alarms_TankNumber_Type_Priority_CreatedTimeStamp",
  216. table: "Alarms",
  217. columns: new[] { "TankNumber", "Type", "Priority", "CreatedTimeStamp" },
  218. unique: true);
  219. migrationBuilder.CreateIndex(
  220. name: "IX_Deliveries_TankNumber_StartingDateTime",
  221. table: "Deliveries",
  222. columns: new[] { "TankNumber", "StartingDateTime" },
  223. unique: true);
  224. migrationBuilder.CreateIndex(
  225. name: "IX_Inventories_TankNumber_TimeStamp",
  226. table: "Inventories",
  227. columns: new[] { "TankNumber", "TimeStamp" },
  228. unique: true);
  229. migrationBuilder.CreateIndex(
  230. name: "IX_TankConfigs_ProbeConfigId",
  231. table: "TankConfigs",
  232. column: "ProbeConfigId");
  233. migrationBuilder.CreateIndex(
  234. name: "IX_TankConfigs_ProductConfigId",
  235. table: "TankConfigs",
  236. column: "ProductConfigId");
  237. migrationBuilder.CreateIndex(
  238. name: "IX_TankConfigs_TankLimitConfigId",
  239. table: "TankConfigs",
  240. column: "TankLimitConfigId");
  241. migrationBuilder.CreateIndex(
  242. name: "IX_TankProfileDatas_TankConfigId",
  243. table: "TankProfileDatas",
  244. column: "TankConfigId");
  245. migrationBuilder.CreateIndex(
  246. name: "IX_TankProfileDatas_BatchLabel_Height",
  247. table: "TankProfileDatas",
  248. columns: new[] { "BatchLabel", "Height" },
  249. unique: true);
  250. }
  251. protected override void Down(MigrationBuilder migrationBuilder)
  252. {
  253. migrationBuilder.DropTable(
  254. name: "Alarms");
  255. migrationBuilder.DropTable(
  256. name: "Deliveries");
  257. migrationBuilder.DropTable(
  258. name: "Inventories");
  259. migrationBuilder.DropTable(
  260. name: "TankOverallConfigs");
  261. migrationBuilder.DropTable(
  262. name: "TankProfileDatas");
  263. migrationBuilder.DropTable(
  264. name: "TankConfigs");
  265. migrationBuilder.DropTable(
  266. name: "ProbeConfigs");
  267. migrationBuilder.DropTable(
  268. name: "ProductConfigs");
  269. migrationBuilder.DropTable(
  270. name: "TankLimitConfigs");
  271. }
  272. }
  273. }