using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace EmployeeManagmentDataBaseImplement.Migrations { /// public partial class Init : 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), Name = table.Column(type: "text", nullable: false), Surname = table.Column(type: "text", nullable: false), Patronymic = table.Column(type: "text", nullable: true), 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: true), EndJob = table.Column(type: "timestamp with time zone", nullable: true), PartTimeJob = table.Column(type: "text", nullable: true), Bid = table.Column(type: "real", nullable: false), PhisicalPersonsId = table.Column(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(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), Data = table.Column(type: "timestamp with time zone", nullable: true), Passed = table.Column(type: "boolean", nullable: false), EmployeesId = table.Column(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(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), EmployeesId = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Salaries"); migrationBuilder.DropTable( name: "Vacations"); migrationBuilder.DropTable( name: "Employees"); migrationBuilder.DropTable( name: "PhysicalPersons"); } } }