134 lines
6.1 KiB
C#
134 lines
6.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace EmployeeManager.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitDB : 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),
|
|
NamePhysicalPersons = table.Column<string>(type: "text", nullable: false),
|
|
SurnamePhysicalPersons = table.Column<string>(type: "text", nullable: false),
|
|
PatronomicPhysicalPersons = table.Column<string>(type: "text", nullable: false),
|
|
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: false),
|
|
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),
|
|
PhysicalPersonsId = table.Column<int>(type: "integer", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Employees", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Employees_PhysicalPersons_PhysicalPersonsId",
|
|
column: x => x.PhysicalPersonsId,
|
|
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),
|
|
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
Passed = table.Column<bool>(type: "boolean", nullable: false),
|
|
EmployeeId = table.Column<int>(type: "integer", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Salaries", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Salaries_Employees_EmployeeId",
|
|
column: x => x.EmployeeId,
|
|
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),
|
|
EmployeeId = table.Column<int>(type: "integer", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Vacations", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Vacations_Employees_EmployeeId",
|
|
column: x => x.EmployeeId,
|
|
principalTable: "Employees",
|
|
principalColumn: "Id");
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Employees_PhysicalPersonsId",
|
|
table: "Employees",
|
|
column: "PhysicalPersonsId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Salaries_EmployeeId",
|
|
table: "Salaries",
|
|
column: "EmployeeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Vacations_EmployeeId",
|
|
table: "Vacations",
|
|
column: "EmployeeId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Salaries");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Vacations");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Employees");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PhysicalPersons");
|
|
}
|
|
}
|
|
}
|