using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace CanteenDatabaseImplement.Migrations { /// public partial class InitialMigr : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Managers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), FIO = table.Column(type: "nvarchar(max)", nullable: false), Login = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), PhoneNumber = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Managers", x => x.Id); }); migrationBuilder.CreateTable( name: "Visitors", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), FIO = table.Column(type: "nvarchar(max)", nullable: false), Login = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), PhoneNumber = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Visitors", x => x.Id); }); migrationBuilder.CreateTable( name: "Cooks", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ManagerId = table.Column(type: "int", nullable: false), FIO = table.Column(type: "nvarchar(max)", nullable: false), Position = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DishName = table.Column(type: "nvarchar(max)", nullable: false), Price = table.Column(type: "float", nullable: false), ManagerId = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProductName = table.Column(type: "nvarchar(max)", nullable: false), Price = table.Column(type: "float", nullable: false), ManagerId = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), VisitorId = table.Column(type: "int", nullable: false), LunchName = table.Column(type: "nvarchar(max)", nullable: false), Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), DateCreate = table.Column(type: "datetime2", nullable: false), DateImplement = table.Column(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: "Tablewares", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), VisitorId = table.Column(type: "int", nullable: false), TablewareName = table.Column(type: "nvarchar(max)", nullable: false), Count = table.Column(type: "int", 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 { DishId = table.Column(type: "int", nullable: false), ProductId = table.Column(type: "int", nullable: false), Id = table.Column(type: "int", nullable: false), CountProducts = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DishProduct", x => new { x.DishId, x.ProductId }); table.ForeignKey( name: "FK_DishProduct_Dishes_DishId", column: x => x.DishId, principalTable: "Dishes", principalColumn: "Id"); table.ForeignKey( name: "FK_DishProduct_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "ProductCook", columns: table => new { ProductId = table.Column(type: "int", nullable: false), CookId = table.Column(type: "int", nullable: false), Id = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ProductCook", x => new { x.ProductId, x.CookId }); table.ForeignKey( name: "FK_ProductCook_Cooks_CookId", column: x => x.CookId, principalTable: "Cooks", principalColumn: "Id"); table.ForeignKey( name: "FK_ProductCook_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "LunchProduct", columns: table => new { LunchId = table.Column(type: "int", nullable: false), ProductId = table.Column(type: "int", nullable: false), Id = table.Column(type: "int", nullable: false), CountProducts = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LunchProduct", x => new { x.LunchId, x.ProductId }); table.ForeignKey( name: "FK_LunchProduct_Lunches_LunchId", column: x => x.LunchId, principalTable: "Lunches", principalColumn: "Id"); table.ForeignKey( name: "FK_LunchProduct_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Orders", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), VisitorId = table.Column(type: "int", nullable: false), TablewareId = table.Column(type: "int", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Sum = table.Column(type: "float", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); table.ForeignKey( name: "FK_Orders_Tablewares_TablewareId", column: x => x.TablewareId, principalTable: "Tablewares", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Orders_Visitors_VisitorId", column: x => x.VisitorId, principalTable: "Visitors", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "LunchOrder", columns: table => new { LunchId = table.Column(type: "int", nullable: false), OrderId = table.Column(type: "int", nullable: false), Id = table.Column(type: "int", nullable: false), CountOrders = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LunchOrder", x => new { x.LunchId, x.OrderId }); table.ForeignKey( name: "FK_LunchOrder_Lunches_LunchId", column: x => x.LunchId, principalTable: "Lunches", principalColumn: "Id"); table.ForeignKey( name: "FK_LunchOrder_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "OrderCook", columns: table => new { CookId = table.Column(type: "int", nullable: false), OrderId = table.Column(type: "int", nullable: false), Id = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrderCook", x => new { x.OrderId, x.CookId }); table.ForeignKey( name: "FK_OrderCook_Cooks_CookId", column: x => x.CookId, principalTable: "Cooks", principalColumn: "Id"); table.ForeignKey( name: "FK_OrderCook_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "OrderDish", columns: table => new { OrderId = table.Column(type: "int", nullable: false), DishId = table.Column(type: "int", nullable: false), Id = table.Column(type: "int", nullable: false), CountDishes = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrderDish", x => new { x.OrderId, x.DishId }); table.ForeignKey( name: "FK_OrderDish_Dishes_DishId", column: x => x.DishId, principalTable: "Dishes", principalColumn: "Id"); table.ForeignKey( name: "FK_OrderDish_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id"); }); 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_ProductId", table: "DishProduct", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Lunches_VisitorId", table: "Lunches", column: "VisitorId"); migrationBuilder.CreateIndex( name: "IX_LunchOrder_OrderId", table: "LunchOrder", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_LunchProduct_ProductId", table: "LunchProduct", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_OrderCook_CookId", table: "OrderCook", column: "CookId"); migrationBuilder.CreateIndex( name: "IX_OrderDish_DishId", table: "OrderDish", column: "DishId"); migrationBuilder.CreateIndex( name: "IX_Orders_TablewareId", table: "Orders", column: "TablewareId"); migrationBuilder.CreateIndex( name: "IX_Orders_VisitorId", table: "Orders", column: "VisitorId"); migrationBuilder.CreateIndex( name: "IX_ProductCook_CookId", table: "ProductCook", column: "CookId"); migrationBuilder.CreateIndex( name: "IX_Products_ManagerId", table: "Products", column: "ManagerId"); migrationBuilder.CreateIndex( name: "IX_Tablewares_VisitorId", table: "Tablewares", column: "VisitorId"); } /// 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: "OrderDish"); migrationBuilder.DropTable( name: "ProductCook"); migrationBuilder.DropTable( name: "Lunches"); migrationBuilder.DropTable( name: "Dishes"); migrationBuilder.DropTable( name: "Orders"); migrationBuilder.DropTable( name: "Cooks"); migrationBuilder.DropTable( name: "Products"); migrationBuilder.DropTable( name: "Tablewares"); migrationBuilder.DropTable( name: "Managers"); migrationBuilder.DropTable( name: "Visitors"); } } }