408 lines
18 KiB
C#
408 lines
18 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace DatabaseImplement.Migrations
|
|
{
|
|
public partial class init : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Guarantors",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Email = table.Column<string>(type: "text", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Login = table.Column<string>(type: "text", nullable: false),
|
|
Password = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Guarantors", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Implementers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Email = table.Column<string>(type: "text", nullable: false),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Login = table.Column<string>(type: "text", nullable: false),
|
|
Password = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Implementers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Machines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Title = table.Column<string>(type: "text", nullable: false),
|
|
Country = table.Column<string>(type: "text", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Machines", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Machines_Guarantors_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Guarantors",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Workers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Birthday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Specialization = table.Column<string>(type: "text", nullable: false),
|
|
Salary = table.Column<double>(type: "double precision", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Workers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Workers_Guarantors_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Guarantors",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Details",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Cost = table.Column<double>(type: "double precision", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Details", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Details_Implementers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Implementers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Productions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Cost = table.Column<double>(type: "double precision", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Productions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Productions_Implementers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Implementers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Products",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Cost = table.Column<double>(type: "double precision", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false),
|
|
MachineId = table.Column<int>(type: "integer", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Products", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Products_Implementers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Implementers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Products_Machines_MachineId",
|
|
column: x => x.MachineId,
|
|
principalTable: "Machines",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "WorkerMachines",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
WorkerId = table.Column<int>(type: "integer", nullable: false),
|
|
MachineId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_WorkerMachines", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_WorkerMachines_Machines_WorkerId",
|
|
column: x => x.WorkerId,
|
|
principalTable: "Machines",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_WorkerMachines_Workers_WorkerId",
|
|
column: x => x.WorkerId,
|
|
principalTable: "Workers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DetailProductions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
DetailId = table.Column<int>(type: "integer", nullable: false),
|
|
ProductionId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DetailProductions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DetailProductions_Details_DetailId",
|
|
column: x => x.DetailId,
|
|
principalTable: "Details",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DetailProductions_Productions_ProductionId",
|
|
column: x => x.ProductionId,
|
|
principalTable: "Productions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Workshops",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Title = table.Column<string>(type: "text", nullable: false),
|
|
Address = table.Column<string>(type: "text", nullable: false),
|
|
Director = table.Column<string>(type: "text", nullable: false),
|
|
UserId = table.Column<int>(type: "integer", nullable: false),
|
|
ProductionId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Workshops", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Workshops_Guarantors_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Guarantors",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Workshops_Productions_ProductionId",
|
|
column: x => x.ProductionId,
|
|
principalTable: "Productions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "DetailProducts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
DetailId = table.Column<int>(type: "integer", nullable: false),
|
|
ProductId = table.Column<int>(type: "integer", nullable: false),
|
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DetailProducts", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_DetailProducts_Details_DetailId",
|
|
column: x => x.DetailId,
|
|
principalTable: "Details",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_DetailProducts_Products_ProductId",
|
|
column: x => x.ProductId,
|
|
principalTable: "Products",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "WorkerWorkshops",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
WorkerId = table.Column<int>(type: "integer", nullable: false),
|
|
WorkshopId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_WorkerWorkshops", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_WorkerWorkshops_Workers_WorkerId",
|
|
column: x => x.WorkerId,
|
|
principalTable: "Workers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_WorkerWorkshops_Workshops_WorkshopId",
|
|
column: x => x.WorkshopId,
|
|
principalTable: "Workshops",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DetailProductions_DetailId",
|
|
table: "DetailProductions",
|
|
column: "DetailId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DetailProductions_ProductionId",
|
|
table: "DetailProductions",
|
|
column: "ProductionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DetailProducts_DetailId",
|
|
table: "DetailProducts",
|
|
column: "DetailId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DetailProducts_ProductId",
|
|
table: "DetailProducts",
|
|
column: "ProductId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Details_UserId",
|
|
table: "Details",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Machines_UserId",
|
|
table: "Machines",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Productions_UserId",
|
|
table: "Productions",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Products_MachineId",
|
|
table: "Products",
|
|
column: "MachineId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Products_UserId",
|
|
table: "Products",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_WorkerMachines_WorkerId",
|
|
table: "WorkerMachines",
|
|
column: "WorkerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Workers_UserId",
|
|
table: "Workers",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_WorkerWorkshops_WorkerId",
|
|
table: "WorkerWorkshops",
|
|
column: "WorkerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_WorkerWorkshops_WorkshopId",
|
|
table: "WorkerWorkshops",
|
|
column: "WorkshopId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Workshops_ProductionId",
|
|
table: "Workshops",
|
|
column: "ProductionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Workshops_UserId",
|
|
table: "Workshops",
|
|
column: "UserId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DetailProductions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "DetailProducts");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "WorkerMachines");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "WorkerWorkshops");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Details");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Products");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Workers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Workshops");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Machines");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Productions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Guarantors");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Implementers");
|
|
}
|
|
}
|
|
}
|