95 lines
3.9 KiB
C#
95 lines
3.9 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace Weifer.Database.EF.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class init : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Customers",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
CustomerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|||
|
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
CreatedOn = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Customers", x => x.CustomerId);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "ShoppingLists",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
ShoppingListId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|||
|
CustomerId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|||
|
ShoppingListName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_ShoppingLists", x => x.ShoppingListId);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ShoppingLists_Customers_CustomerId",
|
|||
|
column: x => x.CustomerId,
|
|||
|
principalTable: "Customers",
|
|||
|
principalColumn: "CustomerId",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "ShoppingItems",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
ShoppingItemId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|||
|
ShoppingListId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
|||
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|||
|
Number = table.Column<int>(type: "int", nullable: false),
|
|||
|
Purchased = table.Column<bool>(type: "bit", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_ShoppingItems", x => x.ShoppingItemId);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_ShoppingItems_ShoppingLists_ShoppingListId",
|
|||
|
column: x => x.ShoppingListId,
|
|||
|
principalTable: "ShoppingLists",
|
|||
|
principalColumn: "ShoppingListId",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_ShoppingItems_ShoppingListId",
|
|||
|
table: "ShoppingItems",
|
|||
|
column: "ShoppingListId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_ShoppingLists_CustomerId",
|
|||
|
table: "ShoppingLists",
|
|||
|
column: "CustomerId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "ShoppingItems");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "ShoppingLists");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Customers");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|