All checks were successful
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Successful in 25s
77 lines
2.8 KiB
C#
77 lines
2.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Webshop.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class checkoutcart : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Carts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<string>(type: "text", nullable: true),
|
|
SessionId = table.Column<string>(type: "text", nullable: true),
|
|
LastModified = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Carts", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "CartItems",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CartId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProductId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProductVariantId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
Quantity = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_CartItems", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_CartItems_Carts_CartId",
|
|
column: x => x.CartId,
|
|
principalTable: "Carts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_CartItems_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CartItems_CartId",
|
|
table: "CartItems",
|
|
column: "CartId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_CartItems_ProductId",
|
|
table: "CartItems",
|
|
column: "ProductId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "CartItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Carts");
|
|
}
|
|
}
|
|
}
|