using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Weifer.Database.EF.Migrations
{
///
public partial class init : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
CustomerId = table.Column(type: "uniqueidentifier", nullable: false),
FirstName = table.Column(type: "nvarchar(max)", nullable: false),
LastName = table.Column(type: "nvarchar(max)", nullable: false),
Email = table.Column(type: "nvarchar(max)", nullable: false),
PasswordHash = table.Column(type: "nvarchar(max)", nullable: false),
CreatedOn = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.CustomerId);
});
migrationBuilder.CreateTable(
name: "ShoppingLists",
columns: table => new
{
ShoppingListId = table.Column(type: "uniqueidentifier", nullable: false),
CustomerId = table.Column(type: "uniqueidentifier", nullable: false),
ShoppingListName = table.Column(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(type: "uniqueidentifier", nullable: false),
ShoppingListId = table.Column(type: "uniqueidentifier", nullable: false),
Description = table.Column(type: "nvarchar(max)", nullable: false),
Number = table.Column(type: "int", nullable: false),
Purchased = table.Column(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");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ShoppingItems");
migrationBuilder.DropTable(
name: "ShoppingLists");
migrationBuilder.DropTable(
name: "Customers");
}
}
}