CourseWork_KPO/CandidateReviewDatabaseImplement/Migrations/20241105152221_InitialCreate.cs

262 lines
12 KiB
C#
Raw Permalink Normal View History

2024-11-04 22:26:40 +04:00
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace CandidateReviewDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Companies",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
LogoFilePath = table.Column<string>(type: "text", nullable: true),
2024-11-04 22:26:40 +04:00
Description = table.Column<string>(type: "text", nullable: true),
Website = table.Column<string>(type: "text", nullable: true),
Address = table.Column<string>(type: "text", nullable: true),
Contacts = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Companies", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Criterions",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Type = table.Column<int>(type: "integer", nullable: false),
Description = table.Column<string>(type: "text", nullable: true),
Weight = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Criterions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CompanyId = table.Column<int>(type: "integer", nullable: true),
2024-11-04 22:26:40 +04:00
Surname = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
LastName = table.Column<string>(type: "text", nullable: true),
AvatarFilePath = table.Column<string>(type: "text", nullable: true),
2024-11-04 22:26:40 +04:00
Email = table.Column<string>(type: "text", nullable: false),
Password = table.Column<string>(type: "text", nullable: false),
PhoneNumber = table.Column<string>(type: "text", nullable: true),
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
Role = table.Column<int>(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");
2024-11-04 22:26:40 +04:00
});
migrationBuilder.CreateTable(
name: "Vacancies",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CompanyId = table.Column<int>(type: "integer", nullable: false),
JobTitle = table.Column<string>(type: "text", nullable: false),
Requirements = table.Column<string>(type: "text", nullable: false),
Responsibilities = table.Column<string>(type: "text", nullable: false),
JobType = table.Column<int>(type: "integer", nullable: false),
Salary = table.Column<string>(type: "text", nullable: true),
Description = table.Column<string>(type: "text", nullable: true),
Status = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Tags = table.Column<string>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ResumeId = table.Column<int>(type: "integer", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
Rating = table.Column<int>(type: "integer", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Comment = table.Column<string>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AssessmentId = table.Column<int>(type: "integer", nullable: false),
CriterionId = table.Column<int>(type: "integer", nullable: false),
Value = table.Column<int>(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<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
VacancyId = table.Column<int>(type: "integer", nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
Title = table.Column<string>(type: "text", nullable: false),
Experience = table.Column<string>(type: "text", nullable: false),
Education = table.Column<string>(type: "text", nullable: false),
PhotoFilePath = table.Column<string>(type: "text", nullable: true),
Description = table.Column<string>(type: "text", nullable: true),
Skills = table.Column<string>(type: "text", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false),
ResumeId = table.Column<int>(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");
}
/// <inheritdoc />
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");
}
}
}