83f51c6a23
Added shopping cart and items Added quotes Refactored relatinoships Migrated changes Refactored cqrs commands and queries Refactored mappings
228 lines
9.0 KiB
C#
228 lines
9.0 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace LiteCharms.Infrastructure.Database.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddedQuoteShoppingCartalteredOrderCustomer : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Order_ProductPrice_ProductPriceId",
|
|
table: "Order");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Order_ProductPriceId",
|
|
table: "Order");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "ProductPriceId",
|
|
table: "Order",
|
|
newName: "ShoppingCartId");
|
|
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "QuoteId",
|
|
table: "Order",
|
|
type: "uuid",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ShoppingCart",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
OrderId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
QuoteId = table.Column<Guid>(type: "uuid", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ShoppingCart", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCart_Customer_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Quote",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CustomerId1 = table.Column<Guid>(type: "uuid", nullable: true),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
ExpiredAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
CustomerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ShoppingCartId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
Reason = table.Column<string>(type: "text", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Quote", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Quote_Customer_CustomerId",
|
|
column: x => x.CustomerId,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Quote_Customer_CustomerId1",
|
|
column: x => x.CustomerId1,
|
|
principalTable: "Customer",
|
|
principalColumn: "Id");
|
|
table.ForeignKey(
|
|
name: "FK_Quote_ShoppingCart_ShoppingCartId",
|
|
column: x => x.ShoppingCartId,
|
|
principalTable: "ShoppingCart",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ShoppingCartItems",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ShoppingCartId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProductPriceId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
Quantity = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ShoppingCartItems", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCartItems_ProductPrice_ProductPriceId",
|
|
column: x => x.ProductPriceId,
|
|
principalTable: "ProductPrice",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ShoppingCartItems_ShoppingCart_ShoppingCartId",
|
|
column: x => x.ShoppingCartId,
|
|
principalTable: "ShoppingCart",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Order_QuoteId",
|
|
table: "Order",
|
|
column: "QuoteId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Order_ShoppingCartId",
|
|
table: "Order",
|
|
column: "ShoppingCartId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quote_CustomerId",
|
|
table: "Quote",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quote_CustomerId1",
|
|
table: "Quote",
|
|
column: "CustomerId1");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Quote_ShoppingCartId",
|
|
table: "Quote",
|
|
column: "ShoppingCartId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCart_CustomerId",
|
|
table: "ShoppingCart",
|
|
column: "CustomerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartItems_ProductPriceId",
|
|
table: "ShoppingCartItems",
|
|
column: "ProductPriceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ShoppingCartItems_ShoppingCartId",
|
|
table: "ShoppingCartItems",
|
|
column: "ShoppingCartId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Order_Quote_QuoteId",
|
|
table: "Order",
|
|
column: "QuoteId",
|
|
principalTable: "Quote",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Order_ShoppingCart_ShoppingCartId",
|
|
table: "Order",
|
|
column: "ShoppingCartId",
|
|
principalTable: "ShoppingCart",
|
|
principalColumn: "Id");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Order_Quote_QuoteId",
|
|
table: "Order");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Order_ShoppingCart_ShoppingCartId",
|
|
table: "Order");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Quote");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ShoppingCartItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ShoppingCart");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Order_QuoteId",
|
|
table: "Order");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Order_ShoppingCartId",
|
|
table: "Order");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "QuoteId",
|
|
table: "Order");
|
|
|
|
migrationBuilder.RenameColumn(
|
|
name: "ShoppingCartId",
|
|
table: "Order",
|
|
newName: "ProductPriceId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Order_ProductPriceId",
|
|
table: "Order",
|
|
column: "ProductPriceId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Order_ProductPrice_ProductPriceId",
|
|
table: "Order",
|
|
column: "ProductPriceId",
|
|
principalTable: "ProductPrice",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
}
|
|
}
|