using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace EmployeeManager.Migrations
{
///
public partial class InitDB : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PhysicalPersons",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
NamePhysicalPersons = table.Column(type: "text", nullable: false),
SurnamePhysicalPersons = table.Column(type: "text", nullable: false),
PatronomicPhysicalPersons = table.Column(type: "text", nullable: false),
Birthday = table.Column(type: "timestamp with time zone", nullable: false),
Gender = table.Column(type: "text", nullable: false),
Address = table.Column(type: "text", nullable: false),
Telephone = table.Column(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PhysicalPersons", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Employees",
columns: table => new
{
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
NameJob = table.Column(type: "text", nullable: false),
StartJob = table.Column(type: "timestamp with time zone", nullable: false),
EndJob = table.Column(type: "timestamp with time zone", nullable: true),
PartTimeJob = table.Column(type: "text", nullable: true),
Bid = table.Column(type: "real", nullable: false),
PhysicalPersonsId = table.Column(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(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CountHours = table.Column(type: "integer", nullable: false),
PriceHour = table.Column(type: "real", nullable: false),
Premium = table.Column(type: "real", nullable: true),
Date = table.Column(type: "timestamp with time zone", nullable: true),
Passed = table.Column(type: "boolean", nullable: false),
EmployeeId = table.Column(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(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
StartData = table.Column(type: "timestamp with time zone", nullable: false),
EndData = table.Column(type: "timestamp with time zone", nullable: false),
Passed = table.Column(type: "boolean", nullable: false),
EmployeeId = table.Column(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");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Salaries");
migrationBuilder.DropTable(
name: "Vacations");
migrationBuilder.DropTable(
name: "Employees");
migrationBuilder.DropTable(
name: "PhysicalPersons");
}
}
}