shopping-cart-blazor-wasm/Server/Migrations/20211109100532_Initial.cs

63 lines
2.3 KiB
C#
Raw Normal View History

2020-06-19 10:20:16 +02:00
using Microsoft.EntityFrameworkCore.Migrations;
2021-11-09 11:44:08 +01:00
#nullable disable
2020-06-19 10:20:16 +02:00
namespace ShoppingCartStarter.Server.Migrations
{
2021-11-09 11:44:08 +01:00
public partial class Initial : Migration
2020-06-19 10:20:16 +02:00
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Carts",
columns: table => new
{
2021-11-09 11:44:08 +01:00
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
SessionId = table.Column<int>(type: "INTEGER", nullable: false)
2020-06-19 10:20:16 +02:00
},
constraints: table =>
{
table.PrimaryKey("PK_Carts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "LineItem",
columns: table => new
{
2021-11-09 11:44:08 +01:00
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: true),
Quantity = table.Column<int>(type: "INTEGER", nullable: false),
Price = table.Column<decimal>(type: "TEXT", nullable: false),
Image = table.Column<string>(type: "TEXT", nullable: true),
ShoppingCartId = table.Column<int>(type: "INTEGER", nullable: true)
2020-06-19 10:20:16 +02:00
},
constraints: table =>
{
table.PrimaryKey("PK_LineItem", x => x.Id);
table.ForeignKey(
name: "FK_LineItem_Carts_ShoppingCartId",
column: x => x.ShoppingCartId,
principalTable: "Carts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_LineItem_ShoppingCartId",
table: "LineItem",
column: "ShoppingCartId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LineItem");
migrationBuilder.DropTable(
name: "Carts");
}
}
}