20210415083245_InitialCreate.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using System;
  2. using Microsoft.EntityFrameworkCore.Migrations;
  3. namespace Gateway.POS.Migrations
  4. {
  5. public partial class InitialCreate : Migration
  6. {
  7. protected override void Up(MigrationBuilder migrationBuilder)
  8. {
  9. migrationBuilder.CreateTable(
  10. name: "Discounts",
  11. columns: table => new
  12. {
  13. Id = table.Column<int>(type: "INTEGER", nullable: false)
  14. .Annotation("Sqlite:Autoincrement", true),
  15. IsMarkedAsDeletion = table.Column<bool>(type: "INTEGER", nullable: false),
  16. Name = table.Column<string>(type: "TEXT", nullable: true),
  17. Description = table.Column<string>(type: "TEXT", nullable: true),
  18. DiscountType = table.Column<int>(type: "INTEGER", nullable: false),
  19. StartTime = table.Column<DateTime>(type: "TEXT", nullable: true),
  20. EndTime = table.Column<DateTime>(type: "TEXT", nullable: true),
  21. CreatedTime = table.Column<DateTime>(type: "TEXT", nullable: false),
  22. ModifiedTime = table.Column<DateTime>(type: "TEXT", nullable: true),
  23. TargetFuelProductCode = table.Column<string>(type: "TEXT", nullable: true),
  24. Command = table.Column<string>(type: "TEXT", nullable: true)
  25. },
  26. constraints: table =>
  27. {
  28. table.PrimaryKey("PK_Discounts", x => x.Id);
  29. });
  30. migrationBuilder.CreateTable(
  31. name: "Transactions",
  32. columns: table => new
  33. {
  34. Id = table.Column<int>(type: "INTEGER", nullable: false)
  35. .Annotation("Sqlite:Autoincrement", true),
  36. TransactionType = table.Column<int>(type: "INTEGER", nullable: false),
  37. TotalAmount = table.Column<decimal>(type: "TEXT", nullable: true),
  38. NetAmount = table.Column<decimal>(type: "TEXT", nullable: true),
  39. ReceiptId = table.Column<string>(type: "TEXT", nullable: true),
  40. OperatorId = table.Column<string>(type: "TEXT", nullable: true),
  41. ShiftId = table.Column<string>(type: "TEXT", nullable: true),
  42. TerminalId = table.Column<string>(type: "TEXT", nullable: true),
  43. SiteId = table.Column<string>(type: "TEXT", nullable: true),
  44. ClientSideTimestamp = table.Column<DateTime>(type: "TEXT", nullable: true),
  45. ServerSideTimestamp = table.Column<DateTime>(type: "TEXT", nullable: false),
  46. Comment = table.Column<string>(type: "TEXT", nullable: true)
  47. },
  48. constraints: table =>
  49. {
  50. table.PrimaryKey("PK_Transactions", x => x.Id);
  51. });
  52. migrationBuilder.CreateTable(
  53. name: "AppliedDiscount",
  54. columns: table => new
  55. {
  56. Id = table.Column<int>(type: "INTEGER", nullable: false)
  57. .Annotation("Sqlite:Autoincrement", true),
  58. DiscountId = table.Column<int>(type: "INTEGER", nullable: false),
  59. DiscountedAmount = table.Column<decimal>(type: "TEXT", nullable: false),
  60. TransactionId = table.Column<int>(type: "INTEGER", nullable: true)
  61. },
  62. constraints: table =>
  63. {
  64. table.PrimaryKey("PK_AppliedDiscount", x => x.Id);
  65. table.ForeignKey(
  66. name: "FK_AppliedDiscount_Discounts_DiscountId",
  67. column: x => x.DiscountId,
  68. principalTable: "Discounts",
  69. principalColumn: "Id",
  70. onDelete: ReferentialAction.Cascade);
  71. table.ForeignKey(
  72. name: "FK_AppliedDiscount_Transactions_TransactionId",
  73. column: x => x.TransactionId,
  74. principalTable: "Transactions",
  75. principalColumn: "Id",
  76. onDelete: ReferentialAction.Restrict);
  77. });
  78. migrationBuilder.CreateTable(
  79. name: "FuelItems",
  80. columns: table => new
  81. {
  82. Id = table.Column<int>(type: "INTEGER", nullable: false)
  83. .Annotation("Sqlite:Autoincrement", true),
  84. PumpId = table.Column<int>(type: "INTEGER", nullable: false),
  85. NozzleLogicalId = table.Column<int>(type: "INTEGER", nullable: false),
  86. SiteLevelNozzleId = table.Column<int>(type: "INTEGER", nullable: true),
  87. FuelProductName = table.Column<string>(type: "TEXT", nullable: true),
  88. FuelProductCode = table.Column<string>(type: "TEXT", nullable: true),
  89. Qualtity = table.Column<decimal>(type: "TEXT", nullable: false),
  90. Price = table.Column<decimal>(type: "TEXT", nullable: false),
  91. Amount = table.Column<decimal>(type: "TEXT", nullable: false),
  92. TotalVolume = table.Column<decimal>(type: "TEXT", nullable: true),
  93. FuelTrxSequenceNumber = table.Column<string>(type: "TEXT", nullable: true),
  94. FuelingStartTime = table.Column<DateTime>(type: "TEXT", nullable: true),
  95. FuelingEndTime = table.Column<DateTime>(type: "TEXT", nullable: true),
  96. TransactionId = table.Column<int>(type: "INTEGER", nullable: true)
  97. },
  98. constraints: table =>
  99. {
  100. table.PrimaryKey("PK_FuelItems", x => x.Id);
  101. table.ForeignKey(
  102. name: "FK_FuelItems_Transactions_TransactionId",
  103. column: x => x.TransactionId,
  104. principalTable: "Transactions",
  105. principalColumn: "Id",
  106. onDelete: ReferentialAction.Restrict);
  107. });
  108. migrationBuilder.CreateTable(
  109. name: "Payment",
  110. columns: table => new
  111. {
  112. Id = table.Column<int>(type: "INTEGER", nullable: false)
  113. .Annotation("Sqlite:Autoincrement", true),
  114. Method = table.Column<int>(type: "INTEGER", nullable: false),
  115. AuthCode = table.Column<string>(type: "TEXT", nullable: true),
  116. BillNumber = table.Column<string>(type: "TEXT", nullable: true),
  117. ExpectAmount = table.Column<decimal>(type: "TEXT", nullable: false),
  118. PaidAmount = table.Column<decimal>(type: "TEXT", nullable: false),
  119. TradeStatus = table.Column<int>(type: "INTEGER", nullable: false),
  120. Comment = table.Column<string>(type: "TEXT", nullable: true),
  121. TransactionId = table.Column<int>(type: "INTEGER", nullable: true)
  122. },
  123. constraints: table =>
  124. {
  125. table.PrimaryKey("PK_Payment", x => x.Id);
  126. table.ForeignKey(
  127. name: "FK_Payment_Transactions_TransactionId",
  128. column: x => x.TransactionId,
  129. principalTable: "Transactions",
  130. principalColumn: "Id",
  131. onDelete: ReferentialAction.Restrict);
  132. });
  133. migrationBuilder.CreateIndex(
  134. name: "IX_AppliedDiscount_DiscountId",
  135. table: "AppliedDiscount",
  136. column: "DiscountId");
  137. migrationBuilder.CreateIndex(
  138. name: "IX_AppliedDiscount_TransactionId",
  139. table: "AppliedDiscount",
  140. column: "TransactionId");
  141. migrationBuilder.CreateIndex(
  142. name: "IX_FuelItems_Amount",
  143. table: "FuelItems",
  144. column: "Amount");
  145. migrationBuilder.CreateIndex(
  146. name: "IX_FuelItems_FuelProductCode",
  147. table: "FuelItems",
  148. column: "FuelProductCode");
  149. migrationBuilder.CreateIndex(
  150. name: "IX_FuelItems_PumpId_NozzleLogicalId",
  151. table: "FuelItems",
  152. columns: new[] { "PumpId", "NozzleLogicalId" });
  153. migrationBuilder.CreateIndex(
  154. name: "IX_FuelItems_SiteLevelNozzleId",
  155. table: "FuelItems",
  156. column: "SiteLevelNozzleId");
  157. migrationBuilder.CreateIndex(
  158. name: "IX_FuelItems_TransactionId",
  159. table: "FuelItems",
  160. column: "TransactionId");
  161. migrationBuilder.CreateIndex(
  162. name: "IX_Payment_TransactionId",
  163. table: "Payment",
  164. column: "TransactionId");
  165. migrationBuilder.CreateIndex(
  166. name: "IX_Transactions_Id",
  167. table: "Transactions",
  168. column: "Id",
  169. unique: true);
  170. migrationBuilder.CreateIndex(
  171. name: "IX_Transactions_NetAmount",
  172. table: "Transactions",
  173. column: "NetAmount");
  174. migrationBuilder.CreateIndex(
  175. name: "IX_Transactions_ReceiptId",
  176. table: "Transactions",
  177. column: "ReceiptId",
  178. unique: true);
  179. migrationBuilder.CreateIndex(
  180. name: "IX_Transactions_ServerSideTimestamp",
  181. table: "Transactions",
  182. column: "ServerSideTimestamp");
  183. migrationBuilder.CreateIndex(
  184. name: "IX_Transactions_ShiftId",
  185. table: "Transactions",
  186. column: "ShiftId");
  187. migrationBuilder.CreateIndex(
  188. name: "IX_Transactions_TotalAmount",
  189. table: "Transactions",
  190. column: "TotalAmount");
  191. }
  192. protected override void Down(MigrationBuilder migrationBuilder)
  193. {
  194. migrationBuilder.DropTable(
  195. name: "AppliedDiscount");
  196. migrationBuilder.DropTable(
  197. name: "FuelItems");
  198. migrationBuilder.DropTable(
  199. name: "Payment");
  200. migrationBuilder.DropTable(
  201. name: "Discounts");
  202. migrationBuilder.DropTable(
  203. name: "Transactions");
  204. }
  205. }
  206. }