PIbd-42_Kashin_M.I_CPO_Cour.../EmployeeManagmentDataBaseImplement/Migrations/20241126175607_Init.cs

134 lines
6.0 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace EmployeeManagmentDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PhysicalPersons",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Surname = table.Column<string>(type: "text", nullable: false),
Patronymic = table.Column<string>(type: "text", nullable: true),
Birthday = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Gender = table.Column<string>(type: "text", nullable: false),
Address = table.Column<string>(type: "text", nullable: false),
Telephone = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PhysicalPersons", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
NameJob = table.Column<string>(type: "text", nullable: false),
StartJob = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
EndJob = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
PartTimeJob = table.Column<string>(type: "text", nullable: true),
Bid = table.Column<float>(type: "real", nullable: false),
PhisicalPersonsId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Employees", x => x.Id);
table.ForeignKey(
name: "FK_Employees_PhysicalPersons_PhisicalPersonsId",
column: x => x.PhisicalPersonsId,
principalTable: "PhysicalPersons",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Salaries",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CountHours = table.Column<int>(type: "integer", nullable: false),
PriceHour = table.Column<float>(type: "real", nullable: false),
Premium = table.Column<float>(type: "real", nullable: true),
Data = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Passed = table.Column<bool>(type: "boolean", nullable: false),
EmployeesId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Salaries", x => x.Id);
table.ForeignKey(
name: "FK_Salaries_Employees_EmployeesId",
column: x => x.EmployeesId,
principalTable: "Employees",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Vacations",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StartData = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
EndData = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Passed = table.Column<bool>(type: "boolean", nullable: false),
EmployeesId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Vacations", x => x.Id);
table.ForeignKey(
name: "FK_Vacations_Employees_EmployeesId",
column: x => x.EmployeesId,
principalTable: "Employees",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Employees_PhisicalPersonsId",
table: "Employees",
column: "PhisicalPersonsId");
migrationBuilder.CreateIndex(
name: "IX_Salaries_EmployeesId",
table: "Salaries",
column: "EmployeesId");
migrationBuilder.CreateIndex(
name: "IX_Vacations_EmployeesId",
table: "Vacations",
column: "EmployeesId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Salaries");
migrationBuilder.DropTable(
name: "Vacations");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropTable(
name: "PhysicalPersons");
}
}
}