SUBD_SushiBar/SushiBar/SushiBarDatabaseImplement/Migrations/20240326181255_InitialCreate.cs

153 lines
6.1 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SushiBarDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Buyers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
BuyerName = table.Column<string>(type: "nvarchar(max)", nullable: false),
BuyerBirthDate = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Buyers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Cooks",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CookName = table.Column<string>(type: "nvarchar(max)", nullable: false),
CookSurname = table.Column<string>(type: "nvarchar(max)", nullable: false),
Experience = table.Column<int>(type: "int", nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Passport = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cooks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Menus",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FoodName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Menus", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Places",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PlaceNumber = table.Column<int>(type: "int", nullable: false),
CountPlaces = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Places", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Tasks",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TaskDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Status = table.Column<int>(type: "int", nullable: false),
FullPrice = table.Column<double>(type: "float", nullable: false),
PlaceId = table.Column<int>(type: "int", nullable: false),
CookId = table.Column<int>(type: "int", nullable: false),
BuyerId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tasks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TaskMenus",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TaskId = table.Column<int>(type: "int", nullable: false),
MenuId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TaskMenus", x => x.Id);
table.ForeignKey(
name: "FK_TaskMenus_Menus_MenuId",
column: x => x.MenuId,
principalTable: "Menus",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TaskMenus_Tasks_TaskId",
column: x => x.TaskId,
principalTable: "Tasks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_TaskMenus_MenuId",
table: "TaskMenus",
column: "MenuId");
migrationBuilder.CreateIndex(
name: "IX_TaskMenus_TaskId",
table: "TaskMenus",
column: "TaskId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Buyers");
migrationBuilder.DropTable(
name: "Cooks");
migrationBuilder.DropTable(
name: "Places");
migrationBuilder.DropTable(
name: "TaskMenus");
migrationBuilder.DropTable(
name: "Menus");
migrationBuilder.DropTable(
name: "Tasks");
}
}
}