470 lines
19 KiB
C#
470 lines
19 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace CanteenDatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Managers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Managers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Visitors",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Visitors", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Cooks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ManagerId = table.Column<int>(type: "int", nullable: false),
|
|
FIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Position = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Cooks", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Cooks_Managers_ManagerId",
|
|
column: x => x.ManagerId,
|
|
principalTable: "Managers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Dishes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
DishName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Price = table.Column<double>(type: "float", nullable: false),
|
|
ManagerId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Dishes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Dishes_Managers_ManagerId",
|
|
column: x => x.ManagerId,
|
|
principalTable: "Managers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Products",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ProductName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Price = table.Column<double>(type: "float", nullable: false),
|
|
ManagerId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Products", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Products_Managers_ManagerId",
|
|
column: x => x.ManagerId,
|
|
principalTable: "Managers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Lunches",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
VisitorId = table.Column<int>(type: "int", nullable: false),
|
|
LunchName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Sum = table.Column<double>(type: "float", nullable: false),
|
|
Status = table.Column<int>(type: "int", nullable: false),
|
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Lunches", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Lunches_Visitors_VisitorId",
|
|
column: x => x.VisitorId,
|
|
principalTable: "Visitors",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Orders",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
VisitorId = table.Column<int>(type: "int", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Orders_Visitors_VisitorId",
|
|
column: x => x.VisitorId,
|
|
principalTable: "Visitors",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tablewares",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
VisitorId = table.Column<int>(type: "int", nullable: false),
|
|
TablewareName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tablewares", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Tablewares_Visitors_VisitorId",
|
|
column: x => x.VisitorId,
|
|
principalTable: "Visitors",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DishProduct",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
DishId = table.Column<int>(type: "int", nullable: false),
|
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
|
CountProducts = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DishProduct", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DishProduct_Dishes_DishId",
|
|
column: x => x.DishId,
|
|
principalTable: "Dishes",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_DishProduct_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ProductCook",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
|
CookId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ProductCook", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ProductCook_Cooks_CookId",
|
|
column: x => x.CookId,
|
|
principalTable: "Cooks",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_ProductCook_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LunchProduct",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
LunchId = table.Column<int>(type: "int", nullable: false),
|
|
ProductId = table.Column<int>(type: "int", nullable: false),
|
|
CountProducts = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LunchProduct", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LunchProduct_Lunches_LunchId",
|
|
column: x => x.LunchId,
|
|
principalTable: "Lunches",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_LunchProduct_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "LunchOrder",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
LunchId = table.Column<int>(type: "int", nullable: false),
|
|
OrderId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_LunchOrder", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_LunchOrder_Lunches_LunchId",
|
|
column: x => x.LunchId,
|
|
principalTable: "Lunches",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_LunchOrder_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OrderCook",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
CookId = table.Column<int>(type: "int", nullable: false),
|
|
OrderId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OrderCook", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_OrderCook_Cooks_CookId",
|
|
column: x => x.CookId,
|
|
principalTable: "Cooks",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_OrderCook_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OrderTableware",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
OrderId = table.Column<int>(type: "int", nullable: false),
|
|
TablewareId = table.Column<int>(type: "int", nullable: false),
|
|
CountTablewares = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OrderTableware", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_OrderTableware_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_OrderTableware_Tablewares_TablewareId",
|
|
column: x => x.TablewareId,
|
|
principalTable: "Tablewares",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Cooks_ManagerId",
|
|
table: "Cooks",
|
|
column: "ManagerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Dishes_ManagerId",
|
|
table: "Dishes",
|
|
column: "ManagerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DishProduct_DishId",
|
|
table: "DishProduct",
|
|
column: "DishId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DishProduct_ProductId",
|
|
table: "DishProduct",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Lunches_VisitorId",
|
|
table: "Lunches",
|
|
column: "VisitorId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LunchOrder_LunchId",
|
|
table: "LunchOrder",
|
|
column: "LunchId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LunchOrder_OrderId",
|
|
table: "LunchOrder",
|
|
column: "OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LunchProduct_LunchId",
|
|
table: "LunchProduct",
|
|
column: "LunchId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_LunchProduct_ProductId",
|
|
table: "LunchProduct",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderCook_CookId",
|
|
table: "OrderCook",
|
|
column: "CookId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderCook_OrderId",
|
|
table: "OrderCook",
|
|
column: "OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Orders_VisitorId",
|
|
table: "Orders",
|
|
column: "VisitorId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderTableware_OrderId",
|
|
table: "OrderTableware",
|
|
column: "OrderId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderTableware_TablewareId",
|
|
table: "OrderTableware",
|
|
column: "TablewareId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProductCook_CookId",
|
|
table: "ProductCook",
|
|
column: "CookId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProductCook_ProductId",
|
|
table: "ProductCook",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Products_ManagerId",
|
|
table: "Products",
|
|
column: "ManagerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tablewares_VisitorId",
|
|
table: "Tablewares",
|
|
column: "VisitorId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DishProduct");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LunchOrder");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "LunchProduct");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OrderCook");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OrderTableware");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ProductCook");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Dishes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Lunches");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Orders");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Tablewares");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Cooks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Products");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Visitors");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Managers");
|
|
}
|
|
}
|
|
}
|