186 lines
7.5 KiB
C#
Raw Normal View History

2023-02-27 17:07:02 +04:00
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SushiBarDatabaseImplement.Migrations
{
/// <inheritdoc />
2023-03-28 10:06:56 +04:00
public partial class init : Migration
2023-02-27 17:07:02 +04:00
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Components",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Cost = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Components", x => x.Id);
});
migrationBuilder.CreateTable(
2023-03-28 10:06:56 +04:00
name: "Stores",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StoreName = table.Column<string>(type: "nvarchar(max)", nullable: false),
StoreAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
maxSushi = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Stores", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sushis",
2023-02-27 17:07:02 +04:00
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SushiName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
2023-03-28 10:06:56 +04:00
table.PrimaryKey("PK_Sushis", x => x.Id);
2023-02-27 17:07:02 +04:00
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SushiId = table.Column<int>(type: "int", nullable: false),
SushiName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Count = table.Column<int>(type: "int", 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_Orders", x => x.Id);
table.ForeignKey(
2023-03-28 10:06:56 +04:00
name: "FK_Orders_Sushis_SushiId",
column: x => x.SushiId,
principalTable: "Sushis",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "StoreSushis",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SushiId = table.Column<int>(type: "int", nullable: false),
StoreId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StoreSushis", x => x.Id);
table.ForeignKey(
name: "FK_StoreSushis_Stores_StoreId",
column: x => x.StoreId,
principalTable: "Stores",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_StoreSushis_Sushis_SushiId",
2023-02-27 17:07:02 +04:00
column: x => x.SushiId,
2023-03-28 10:06:56 +04:00
principalTable: "Sushis",
2023-02-27 17:07:02 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "SushiComponents",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SushiId = table.Column<int>(type: "int", nullable: false),
ComponentId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SushiComponents", x => x.Id);
table.ForeignKey(
name: "FK_SushiComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
2023-03-28 10:06:56 +04:00
name: "FK_SushiComponents_Sushis_SushiId",
2023-02-27 17:07:02 +04:00
column: x => x.SushiId,
2023-03-28 10:06:56 +04:00
principalTable: "Sushis",
2023-02-27 17:07:02 +04:00
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Orders_SushiId",
table: "Orders",
column: "SushiId");
2023-03-28 10:06:56 +04:00
migrationBuilder.CreateIndex(
name: "IX_StoreSushis_StoreId",
table: "StoreSushis",
column: "StoreId");
migrationBuilder.CreateIndex(
name: "IX_StoreSushis_SushiId",
table: "StoreSushis",
column: "SushiId");
2023-02-27 17:07:02 +04:00
migrationBuilder.CreateIndex(
name: "IX_SushiComponents_ComponentId",
table: "SushiComponents",
column: "ComponentId");
migrationBuilder.CreateIndex(
name: "IX_SushiComponents_SushiId",
table: "SushiComponents",
column: "SushiId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Orders");
2023-03-28 10:06:56 +04:00
migrationBuilder.DropTable(
name: "StoreSushis");
2023-02-27 17:07:02 +04:00
migrationBuilder.DropTable(
name: "SushiComponents");
2023-03-28 10:06:56 +04:00
migrationBuilder.DropTable(
name: "Stores");
2023-02-27 17:07:02 +04:00
migrationBuilder.DropTable(
name: "Components");
migrationBuilder.DropTable(
2023-03-28 10:06:56 +04:00
name: "Sushis");
2023-02-27 17:07:02 +04:00
}
}
}