using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Infrastructure.Data.Migrations { public partial class OrderEntityAdded : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "DeliveryMethod", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), ShortName = table.Column(type: "TEXT", nullable: true), DeliveryTime = table.Column(type: "TEXT", nullable: true), Description = table.Column(type: "TEXT", nullable: true), Price = table.Column(type: "decimal(18,2)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DeliveryMethod", x => x.Id); }); migrationBuilder.CreateTable( name: "Orders", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), BuyerEmail = table.Column(type: "TEXT", nullable: true), OrderDate = table.Column(type: "TEXT", nullable: false), ShipToAddress_FirstName = table.Column(type: "TEXT", nullable: true), ShipToAddress_LastName = table.Column(type: "TEXT", nullable: true), ShipToAddress_Street = table.Column(type: "TEXT", nullable: true), ShipToAddress_City = table.Column(type: "TEXT", nullable: true), ShipToAddress_State = table.Column(type: "TEXT", nullable: true), ShipToAddress_ZipCode = table.Column(type: "TEXT", nullable: true), DeliveryMethodId = table.Column(type: "INTEGER", nullable: true), Subtotal = table.Column(type: "REAL", nullable: false), Status = table.Column(type: "TEXT", nullable: false), PaymentIntentId = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); table.ForeignKey( name: "FK_Orders_DeliveryMethod_DeliveryMethodId", column: x => x.DeliveryMethodId, principalTable: "DeliveryMethod", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "OrderItems", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), ItemOrdered_ProductItemId = table.Column(type: "INTEGER", nullable: true), ItemOrdered_ProductName = table.Column(type: "TEXT", nullable: true), ItemOrdered_PictureUrl = table.Column(type: "TEXT", nullable: true), Price = table.Column(type: "decimal(18,2)", nullable: false), Quantity = table.Column(type: "INTEGER", nullable: false), OrderId = table.Column(type: "INTEGER", nullable: true) }, constraints: table => { table.PrimaryKey("PK_OrderItems", x => x.Id); table.ForeignKey( name: "FK_OrderItems_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_OrderItems_OrderId", table: "OrderItems", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_Orders_DeliveryMethodId", table: "Orders", column: "DeliveryMethodId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OrderItems"); migrationBuilder.DropTable( name: "Orders"); migrationBuilder.DropTable( name: "DeliveryMethod"); } } }