using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace PersonnelDepartmentDatabaseImplement.Migrations { /// public partial class InitMig : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Departments", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Telephone = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Departments", x => x.Id); }); migrationBuilder.CreateTable( name: "Employees", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FirstName = table.Column(type: "text", nullable: false), LastName = table.Column(type: "text", nullable: false), Patronymic = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Employees", x => x.Id); }); migrationBuilder.CreateTable( name: "Positions", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Positions", x => x.Id); }); migrationBuilder.CreateTable( name: "Types", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Types", x => x.Id); }); migrationBuilder.CreateTable( name: "Deals", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DateFrom = table.Column(type: "timestamp with time zone", nullable: false), DateTo = table.Column(type: "timestamp with time zone", nullable: false), PositionId = table.Column(type: "integer", nullable: false), EmployeeId = table.Column(type: "integer", nullable: false), DepartmentId = table.Column(type: "integer", nullable: false), TypeId = table.Column(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"); } /// 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"); } } }