154 lines
6.5 KiB
C#
154 lines
6.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace SushiBarDatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Buyers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
BuyerName = table.Column<string>(type: "text", nullable: false),
|
|
BuyerBirthDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Buyers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Cooks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
CookName = table.Column<string>(type: "text", nullable: false),
|
|
CookSurname = table.Column<string>(type: "text", nullable: false),
|
|
Experience = table.Column<int>(type: "integer", nullable: false),
|
|
PhoneNumber = table.Column<string>(type: "text", nullable: false),
|
|
Passport = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Cooks", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Menus",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
FoodName = table.Column<string>(type: "text", nullable: false),
|
|
Description = table.Column<string>(type: "text", nullable: false),
|
|
Price = table.Column<double>(type: "double precision", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Menus", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Places",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
PlaceNumber = table.Column<int>(type: "integer", nullable: false),
|
|
CountPlaces = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Places", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tasks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
TaskDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
FullPrice = table.Column<double>(type: "double precision", nullable: false),
|
|
PlaceId = table.Column<int>(type: "integer", nullable: false),
|
|
CookId = table.Column<int>(type: "integer", nullable: false),
|
|
BuyerId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tasks", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "TaskMenus",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
TaskId = table.Column<int>(type: "integer", nullable: false),
|
|
MenuId = table.Column<int>(type: "integer", nullable: false),
|
|
Count = table.Column<int>(type: "integer", 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");
|
|
}
|
|
}
|
|
}
|