using System; using Microsoft.EntityFrameworkCore.Migrations; namespace Gateway.POS.Migrations { public partial class InitialCreate : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Discounts", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), IsMarkedAsDeletion = table.Column(type: "INTEGER", nullable: false), Name = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), DiscountType = table.Column(type: "INTEGER", nullable: false), StartTime = table.Column(type: "TEXT", nullable: true), EndTime = table.Column(type: "TEXT", nullable: true), CreatedTime = table.Column(type: "TEXT", nullable: false), ModifiedTime = table.Column(type: "TEXT", nullable: true), TargetFuelProductCode = table.Column(type: "TEXT", nullable: true), Command = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Discounts", x => x.Id); }); migrationBuilder.CreateTable( name: "Transactions", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), TransactionType = table.Column(type: "INTEGER", nullable: false), TotalAmount = table.Column(type: "TEXT", nullable: true), NetAmount = table.Column(type: "TEXT", nullable: true), ReceiptId = table.Column(type: "TEXT", nullable: true), OperatorId = table.Column(type: "TEXT", nullable: true), ShiftId = table.Column(type: "TEXT", nullable: true), TerminalId = table.Column(type: "TEXT", nullable: true), SiteId = table.Column(type: "TEXT", nullable: true), ClientSideTimestamp = table.Column(type: "TEXT", nullable: true), ServerSideTimestamp = table.Column(type: "TEXT", nullable: false), Comment = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Transactions", x => x.Id); }); migrationBuilder.CreateTable( name: "AppliedDiscount", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), DiscountId = table.Column(type: "INTEGER", nullable: false), DiscountedAmount = table.Column(type: "TEXT", nullable: false), TransactionId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_AppliedDiscount", x => x.Id); table.ForeignKey( name: "FK_AppliedDiscount_Discounts_DiscountId", column: x => x.DiscountId, principalTable: "Discounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AppliedDiscount_Transactions_TransactionId", column: x => x.TransactionId, principalTable: "Transactions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "FuelItems", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), PumpId = table.Column(type: "INTEGER", nullable: false), NozzleLogicalId = table.Column(type: "INTEGER", nullable: false), SiteLevelNozzleId = table.Column(type: "INTEGER", nullable: true), FuelProductName = table.Column(type: "TEXT", nullable: true), FuelProductCode = table.Column(type: "TEXT", nullable: true), Qualtity = table.Column(type: "TEXT", nullable: false), Price = table.Column(type: "TEXT", nullable: false), Amount = table.Column(type: "TEXT", nullable: false), TotalVolume = table.Column(type: "TEXT", nullable: true), FuelTrxSequenceNumber = table.Column(type: "TEXT", nullable: true), FuelingStartTime = table.Column(type: "TEXT", nullable: true), FuelingEndTime = table.Column(type: "TEXT", nullable: true), TransactionId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_FuelItems", x => x.Id); table.ForeignKey( name: "FK_FuelItems_Transactions_TransactionId", column: x => x.TransactionId, principalTable: "Transactions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Payment", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Method = table.Column(type: "INTEGER", nullable: false), AuthCode = table.Column(type: "TEXT", nullable: true), BillNumber = table.Column(type: "TEXT", nullable: true), ExpectAmount = table.Column(type: "TEXT", nullable: false), PaidAmount = table.Column(type: "TEXT", nullable: false), TradeStatus = table.Column(type: "INTEGER", nullable: false), Comment = table.Column(type: "TEXT", nullable: true), TransactionId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Payment", x => x.Id); table.ForeignKey( name: "FK_Payment_Transactions_TransactionId", column: x => x.TransactionId, principalTable: "Transactions", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_AppliedDiscount_DiscountId", table: "AppliedDiscount", column: "DiscountId"); migrationBuilder.CreateIndex( name: "IX_AppliedDiscount_TransactionId", table: "AppliedDiscount", column: "TransactionId"); migrationBuilder.CreateIndex( name: "IX_FuelItems_Amount", table: "FuelItems", column: "Amount"); migrationBuilder.CreateIndex( name: "IX_FuelItems_FuelProductCode", table: "FuelItems", column: "FuelProductCode"); migrationBuilder.CreateIndex( name: "IX_FuelItems_PumpId_NozzleLogicalId", table: "FuelItems", columns: new[] { "PumpId", "NozzleLogicalId" }); migrationBuilder.CreateIndex( name: "IX_FuelItems_SiteLevelNozzleId", table: "FuelItems", column: "SiteLevelNozzleId"); migrationBuilder.CreateIndex( name: "IX_FuelItems_TransactionId", table: "FuelItems", column: "TransactionId"); migrationBuilder.CreateIndex( name: "IX_Payment_TransactionId", table: "Payment", column: "TransactionId"); migrationBuilder.CreateIndex( name: "IX_Transactions_Id", table: "Transactions", column: "Id", unique: true); migrationBuilder.CreateIndex( name: "IX_Transactions_NetAmount", table: "Transactions", column: "NetAmount"); migrationBuilder.CreateIndex( name: "IX_Transactions_ReceiptId", table: "Transactions", column: "ReceiptId", unique: true); migrationBuilder.CreateIndex( name: "IX_Transactions_ServerSideTimestamp", table: "Transactions", column: "ServerSideTimestamp"); migrationBuilder.CreateIndex( name: "IX_Transactions_ShiftId", table: "Transactions", column: "ShiftId"); migrationBuilder.CreateIndex( name: "IX_Transactions_TotalAmount", table: "Transactions", column: "TotalAmount"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AppliedDiscount"); migrationBuilder.DropTable( name: "FuelItems"); migrationBuilder.DropTable( name: "Payment"); migrationBuilder.DropTable( name: "Discounts"); migrationBuilder.DropTable( name: "Transactions"); } } }