PIbd-21_BatylkinaAO_MusoevD.../Canteen/CanteenDatabaseImplement/Migrations/20230519185610_Init.cs

470 lines
19 KiB
C#
Raw Normal View History

2023-04-09 00:34:25 +04:00
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CanteenDatabaseImplement.Migrations
{
/// <inheritdoc />
2023-05-19 03:39:58 +04:00
public partial class Init : Migration
2023-04-09 00:34:25 +04:00
{
/// <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);
});
2023-05-19 03:39:58 +04:00
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),
2023-05-20 00:18:48 +04:00
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
2023-05-19 03:39:58 +04:00
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Visitors_VisitorId",
column: x => x.VisitorId,
principalTable: "Visitors",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
2023-05-19 03:39:58 +04:00
});
2023-04-09 00:34:25 +04:00
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),
2023-05-18 01:40:11 +04:00
TablewareName = table.Column<string>(type: "nvarchar(max)", nullable: false)
2023-04-09 00:34:25 +04:00
},
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
{
2023-05-19 03:39:58 +04:00
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
2023-04-09 00:34:25 +04:00
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 =>
{
2023-05-19 03:39:58 +04:00
table.PrimaryKey("PK_DishProduct", x => x.Id);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_DishProduct_Dishes_DishId",
column: x => x.DishId,
principalTable: "Dishes",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_DishProduct_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
});
migrationBuilder.CreateTable(
name: "ProductCook",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
2023-05-19 03:39:58 +04:00
.Annotation("SqlServer:Identity", "1, 1"),
ProductId = table.Column<int>(type: "int", nullable: false),
CookId = table.Column<int>(type: "int", nullable: false)
2023-04-09 00:34:25 +04:00
},
constraints: table =>
{
2023-05-19 03:39:58 +04:00
table.PrimaryKey("PK_ProductCook", x => x.Id);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_ProductCook_Cooks_CookId",
column: x => x.CookId,
principalTable: "Cooks",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_ProductCook_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
});
migrationBuilder.CreateTable(
name: "LunchProduct",
columns: table => new
{
2023-05-19 03:39:58 +04:00
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
2023-04-09 00:34:25 +04:00
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 =>
{
2023-05-19 03:39:58 +04:00
table.PrimaryKey("PK_LunchProduct", x => x.Id);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_LunchProduct_Lunches_LunchId",
column: x => x.LunchId,
principalTable: "Lunches",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_LunchProduct_Products_ProductId",
column: x => x.ProductId,
principalTable: "Products",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
});
migrationBuilder.CreateTable(
2023-05-19 03:39:58 +04:00
name: "LunchOrder",
2023-04-09 00:34:25 +04:00
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
LunchId = table.Column<int>(type: "int", nullable: false),
2023-05-20 00:18:48 +04:00
OrderId = table.Column<int>(type: "int", nullable: false)
2023-04-09 00:34:25 +04:00
},
constraints: table =>
{
2023-05-19 03:39:58 +04:00
table.PrimaryKey("PK_LunchOrder", x => x.Id);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_LunchOrder_Lunches_LunchId",
column: x => x.LunchId,
principalTable: "Lunches",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_LunchOrder_Orders_OrderId",
column: x => x.OrderId,
principalTable: "Orders",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
});
migrationBuilder.CreateTable(
name: "OrderCook",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
2023-05-19 03:39:58 +04:00
.Annotation("SqlServer:Identity", "1, 1"),
CookId = table.Column<int>(type: "int", nullable: false),
OrderId = table.Column<int>(type: "int", nullable: false)
2023-04-09 00:34:25 +04:00
},
constraints: table =>
{
2023-05-19 03:39:58 +04:00
table.PrimaryKey("PK_OrderCook", x => x.Id);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_OrderCook_Cooks_CookId",
column: x => x.CookId,
principalTable: "Cooks",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
name: "FK_OrderCook_Orders_OrderId",
column: x => x.OrderId,
principalTable: "Orders",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
});
migrationBuilder.CreateTable(
2023-05-19 03:39:58 +04:00
name: "OrderTableware",
2023-04-09 00:34:25 +04:00
columns: table => new
{
2023-05-19 03:39:58 +04:00
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
2023-04-09 00:34:25 +04:00
OrderId = table.Column<int>(type: "int", nullable: false),
2023-05-19 03:39:58 +04:00
TablewareId = table.Column<int>(type: "int", nullable: false),
CountTablewares = table.Column<int>(type: "int", nullable: false)
2023-04-09 00:34:25 +04:00
},
constraints: table =>
{
2023-05-19 03:39:58 +04:00
table.PrimaryKey("PK_OrderTableware", x => x.Id);
2023-04-09 00:34:25 +04:00
table.ForeignKey(
2023-05-19 03:39:58 +04:00
name: "FK_OrderTableware_Orders_OrderId",
2023-04-09 00:34:25 +04:00
column: x => x.OrderId,
principalTable: "Orders",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-05-19 03:39:58 +04:00
table.ForeignKey(
name: "FK_OrderTableware_Tablewares_TablewareId",
column: x => x.TablewareId,
principalTable: "Tablewares",
2023-05-20 00:18:48 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
2023-04-09 00:34:25 +04:00
});
migrationBuilder.CreateIndex(
name: "IX_Cooks_ManagerId",
table: "Cooks",
column: "ManagerId");
migrationBuilder.CreateIndex(
name: "IX_Dishes_ManagerId",
table: "Dishes",
column: "ManagerId");
2023-05-19 03:39:58 +04:00
migrationBuilder.CreateIndex(
name: "IX_DishProduct_DishId",
table: "DishProduct",
column: "DishId");
2023-04-09 00:34:25 +04:00
migrationBuilder.CreateIndex(
name: "IX_DishProduct_ProductId",
table: "DishProduct",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_Lunches_VisitorId",
table: "Lunches",
column: "VisitorId");
2023-05-19 03:39:58 +04:00
migrationBuilder.CreateIndex(
name: "IX_LunchOrder_LunchId",
table: "LunchOrder",
column: "LunchId");
2023-04-09 00:34:25 +04:00
migrationBuilder.CreateIndex(
name: "IX_LunchOrder_OrderId",
table: "LunchOrder",
column: "OrderId");
2023-05-19 03:39:58 +04:00
migrationBuilder.CreateIndex(
name: "IX_LunchProduct_LunchId",
table: "LunchProduct",
column: "LunchId");
2023-04-09 00:34:25 +04:00
migrationBuilder.CreateIndex(
name: "IX_LunchProduct_ProductId",
table: "LunchProduct",
column: "ProductId");
migrationBuilder.CreateIndex(
name: "IX_OrderCook_CookId",
table: "OrderCook",
column: "CookId");
migrationBuilder.CreateIndex(
2023-05-19 03:39:58 +04:00
name: "IX_OrderCook_OrderId",
table: "OrderCook",
column: "OrderId");
2023-04-09 00:34:25 +04:00
migrationBuilder.CreateIndex(
name: "IX_Orders_VisitorId",
table: "Orders",
column: "VisitorId");
2023-05-19 03:39:58 +04:00
migrationBuilder.CreateIndex(
name: "IX_OrderTableware_OrderId",
table: "OrderTableware",
column: "OrderId");
migrationBuilder.CreateIndex(
name: "IX_OrderTableware_TablewareId",
table: "OrderTableware",
column: "TablewareId");
2023-04-09 00:34:25 +04:00
migrationBuilder.CreateIndex(
name: "IX_ProductCook_CookId",
table: "ProductCook",
column: "CookId");
2023-05-19 03:39:58 +04:00
migrationBuilder.CreateIndex(
name: "IX_ProductCook_ProductId",
table: "ProductCook",
column: "ProductId");
2023-04-09 00:34:25 +04:00
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(
2023-05-19 03:39:58 +04:00
name: "OrderTableware");
2023-04-09 00:34:25 +04:00
migrationBuilder.DropTable(
name: "ProductCook");
migrationBuilder.DropTable(
2023-05-19 03:39:58 +04:00
name: "Dishes");
2023-04-09 00:34:25 +04:00
migrationBuilder.DropTable(
2023-05-19 03:39:58 +04:00
name: "Lunches");
2023-04-09 00:34:25 +04:00
migrationBuilder.DropTable(
name: "Orders");
2023-05-19 03:39:58 +04:00
migrationBuilder.DropTable(
name: "Tablewares");
2023-04-09 00:34:25 +04:00
migrationBuilder.DropTable(
name: "Cooks");
migrationBuilder.DropTable(
name: "Products");
migrationBuilder.DropTable(
2023-05-19 03:39:58 +04:00
name: "Visitors");
2023-04-09 00:34:25 +04:00
migrationBuilder.DropTable(
name: "Managers");
}
}
}