using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace CandidateReviewDatabaseImplement.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Companies", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), LogoFilePath = table.Column(type: "text", nullable: true), Description = table.Column(type: "text", nullable: true), Website = table.Column(type: "text", nullable: true), Address = table.Column(type: "text", nullable: true), Contacts = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Companies", x => x.Id); }); migrationBuilder.CreateTable( name: "Criterions", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Type = table.Column(type: "integer", nullable: false), Description = table.Column(type: "text", nullable: true), Weight = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Criterions", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CompanyId = table.Column(type: "integer", nullable: true), Surname = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), LastName = table.Column(type: "text", nullable: true), AvatarFilePath = table.Column(type: "text", nullable: true), Email = table.Column(type: "text", nullable: false), Password = table.Column(type: "text", nullable: false), PhoneNumber = table.Column(type: "text", nullable: true), EmailConfirmed = table.Column(type: "boolean", nullable: false), Role = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); table.ForeignKey( name: "FK_Users_Companies_CompanyId", column: x => x.CompanyId, principalTable: "Companies", principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Vacancies", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CompanyId = table.Column(type: "integer", nullable: false), JobTitle = table.Column(type: "text", nullable: false), Requirements = table.Column(type: "text", nullable: false), Responsibilities = table.Column(type: "text", nullable: false), JobType = table.Column(type: "integer", nullable: false), Salary = table.Column(type: "text", nullable: true), Description = table.Column(type: "text", nullable: true), Status = table.Column(type: "integer", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), Tags = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Vacancies", x => x.Id); table.ForeignKey( name: "FK_Vacancies_Companies_CompanyId", column: x => x.CompanyId, principalTable: "Companies", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Assessments", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ResumeId = table.Column(type: "integer", nullable: false), UserId = table.Column(type: "integer", nullable: false), Rating = table.Column(type: "integer", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), Comment = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Assessments", x => x.Id); table.ForeignKey( name: "FK_Assessments_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "AssessmentCriterions", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), AssessmentId = table.Column(type: "integer", nullable: false), CriterionId = table.Column(type: "integer", nullable: false), Value = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AssessmentCriterions", x => x.Id); table.ForeignKey( name: "FK_AssessmentCriterions_Assessments_AssessmentId", column: x => x.AssessmentId, principalTable: "Assessments", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AssessmentCriterions_Criterions_CriterionId", column: x => x.CriterionId, principalTable: "Criterions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Resumes", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), VacancyId = table.Column(type: "integer", nullable: false), UserId = table.Column(type: "integer", nullable: false), Title = table.Column(type: "text", nullable: false), Experience = table.Column(type: "text", nullable: false), Education = table.Column(type: "text", nullable: false), PhotoFilePath = table.Column(type: "text", nullable: true), Description = table.Column(type: "text", nullable: true), Skills = table.Column(type: "text", nullable: false), Status = table.Column(type: "integer", nullable: false), ResumeId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Resumes", x => x.Id); table.ForeignKey( name: "FK_Resumes_Assessments_ResumeId", column: x => x.ResumeId, principalTable: "Assessments", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Resumes_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Resumes_Vacancies_VacancyId", column: x => x.VacancyId, principalTable: "Vacancies", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AssessmentCriterions_AssessmentId", table: "AssessmentCriterions", column: "AssessmentId"); migrationBuilder.CreateIndex( name: "IX_AssessmentCriterions_CriterionId", table: "AssessmentCriterions", column: "CriterionId"); migrationBuilder.CreateIndex( name: "IX_Assessments_UserId", table: "Assessments", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Resumes_ResumeId", table: "Resumes", column: "ResumeId", unique: true); migrationBuilder.CreateIndex( name: "IX_Resumes_UserId", table: "Resumes", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Resumes_VacancyId", table: "Resumes", column: "VacancyId"); migrationBuilder.CreateIndex( name: "IX_Users_CompanyId", table: "Users", column: "CompanyId"); migrationBuilder.CreateIndex( name: "IX_Vacancies_CompanyId", table: "Vacancies", column: "CompanyId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AssessmentCriterions"); migrationBuilder.DropTable( name: "Resumes"); migrationBuilder.DropTable( name: "Criterions"); migrationBuilder.DropTable( name: "Assessments"); migrationBuilder.DropTable( name: "Vacancies"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Companies"); } } }