153 lines
6.2 KiB
C#
153 lines
6.2 KiB
C#
|
using System;
|
|||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||
|
|
|||
|
#nullable disable
|
|||
|
|
|||
|
namespace PersonnelDepartmentDatabaseImplement.Migrations
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
public partial class InitMig : Migration
|
|||
|
{
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Departments",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false),
|
|||
|
Telephone = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Departments", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Employees",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
FirstName = table.Column<string>(type: "text", nullable: false),
|
|||
|
LastName = table.Column<string>(type: "text", nullable: false),
|
|||
|
Patronymic = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Employees", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Positions",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Positions", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Types",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
Name = table.Column<string>(type: "text", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Types", x => x.Id);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateTable(
|
|||
|
name: "Deals",
|
|||
|
columns: table => new
|
|||
|
{
|
|||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|||
|
DateFrom = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|||
|
DateTo = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|||
|
PositionId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
EmployeeId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
DepartmentId = table.Column<int>(type: "integer", nullable: false),
|
|||
|
TypeId = table.Column<int>(type: "integer", nullable: false)
|
|||
|
},
|
|||
|
constraints: table =>
|
|||
|
{
|
|||
|
table.PrimaryKey("PK_Deals", x => x.Id);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Deals_Departments_DepartmentId",
|
|||
|
column: x => x.DepartmentId,
|
|||
|
principalTable: "Departments",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Deals_Employees_EmployeeId",
|
|||
|
column: x => x.EmployeeId,
|
|||
|
principalTable: "Employees",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Deals_Positions_PositionId",
|
|||
|
column: x => x.PositionId,
|
|||
|
principalTable: "Positions",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
table.ForeignKey(
|
|||
|
name: "FK_Deals_Types_TypeId",
|
|||
|
column: x => x.TypeId,
|
|||
|
principalTable: "Types",
|
|||
|
principalColumn: "Id",
|
|||
|
onDelete: ReferentialAction.Cascade);
|
|||
|
});
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Deals_DepartmentId",
|
|||
|
table: "Deals",
|
|||
|
column: "DepartmentId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Deals_EmployeeId",
|
|||
|
table: "Deals",
|
|||
|
column: "EmployeeId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Deals_PositionId",
|
|||
|
table: "Deals",
|
|||
|
column: "PositionId");
|
|||
|
|
|||
|
migrationBuilder.CreateIndex(
|
|||
|
name: "IX_Deals_TypeId",
|
|||
|
table: "Deals",
|
|||
|
column: "TypeId");
|
|||
|
}
|
|||
|
|
|||
|
/// <inheritdoc />
|
|||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|||
|
{
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Deals");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Departments");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Employees");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Positions");
|
|||
|
|
|||
|
migrationBuilder.DropTable(
|
|||
|
name: "Types");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|