218 lines
9.9 KiB
C#
218 lines
9.9 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace ConstructionFirmDatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class EmployeeMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Clients",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Organization = table.Column<string>(type: "text", nullable: false),
|
|
ContractPerson = table.Column<string>(type: "text", nullable: false),
|
|
Phone = table.Column<string>(type: "text", nullable: false),
|
|
Email = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ConstructionMaterials",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
MaterialName = table.Column<string>(type: "text", nullable: false),
|
|
Cost = table.Column<int>(type: "integer", nullable: false),
|
|
Quantity = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ConstructionMaterials", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Employees",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
FullName = table.Column<string>(type: "text", nullable: false),
|
|
Phone = table.Column<string>(type: "text", nullable: false),
|
|
HireDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
TeamId = table.Column<int>(type: "integer", nullable: false),
|
|
SpecialtyId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Employees", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Projects",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
ClientName = table.Column<string>(type: "text", nullable: false),
|
|
ObjectType = table.Column<string>(type: "text", nullable: false),
|
|
LocationP = table.Column<string>(type: "text", nullable: false),
|
|
Budget = table.Column<int>(type: "integer", nullable: false),
|
|
DeadLine = 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),
|
|
CliendId = table.Column<int>(type: "integer", nullable: false),
|
|
EmployeeId = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Projects", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Specialtys",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
SpecialtyName = table.Column<string>(type: "text", nullable: false),
|
|
Salary = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Specialtys", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Teams",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
TeamName = table.Column<string>(type: "text", nullable: false),
|
|
LeaderName = table.Column<string>(type: "text", nullable: false),
|
|
Experince = table.Column<int>(type: "integer", nullable: false),
|
|
TeamType = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Teams", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ConstructionMaterialProjects",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
ProjectId = table.Column<int>(type: "integer", nullable: false),
|
|
ConstructionMaterialId = table.Column<int>(type: "integer", nullable: false),
|
|
Count = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ConstructionMaterialProjects", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ConstructionMaterialProjects_ConstructionMaterials_Construc~",
|
|
column: x => x.ConstructionMaterialId,
|
|
principalTable: "ConstructionMaterials",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ConstructionMaterialProjects_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ProjectTeams",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
ProjectId = table.Column<int>(type: "integer", nullable: false),
|
|
TeamId = table.Column<int>(type: "integer", nullable: false),
|
|
CountTeam = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ProjectTeams", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ProjectTeams_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ProjectTeams_Teams_TeamId",
|
|
column: x => x.TeamId,
|
|
principalTable: "Teams",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ConstructionMaterialProjects_ConstructionMaterialId",
|
|
table: "ConstructionMaterialProjects",
|
|
column: "ConstructionMaterialId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ConstructionMaterialProjects_ProjectId",
|
|
table: "ConstructionMaterialProjects",
|
|
column: "ProjectId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProjectTeams_ProjectId",
|
|
table: "ProjectTeams",
|
|
column: "ProjectId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProjectTeams_TeamId",
|
|
table: "ProjectTeams",
|
|
column: "TeamId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Clients");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ConstructionMaterialProjects");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Employees");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ProjectTeams");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Specialtys");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ConstructionMaterials");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Projects");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Teams");
|
|
}
|
|
}
|
|
}
|