using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace vendorApproverBackend.Migrations
{
///
public partial class AddUserProfileAttributes : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "code",
table: "users_table",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "departement",
table: "users_table",
type: "text",
nullable: true);
migrationBuilder.AddColumn(
name: "position",
table: "users_table",
type: "text",
nullable: true);
migrationBuilder.CreateTable(
name: "Degrees",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Institution = table.Column(type: "character varying(255)", maxLength: 255, nullable: false),
completion_year = table.Column(type: "integer", nullable: false),
file_id = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Degrees", x => x.Id);
});
migrationBuilder.CreateTable(
name: "EmployeeCertifications",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false),
file_id = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeeCertifications", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserApplicationCategories",
columns: table => new
{
CategoriesId = table.Column(type: "bigint", nullable: false),
UserId = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserApplicationCategories", x => new { x.CategoriesId, x.UserId });
table.ForeignKey(
name: "FK_UserApplicationCategories_ApplicationCategories_CategoriesId",
column: x => x.CategoriesId,
principalTable: "ApplicationCategories",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserApplicationCategories_users_table_UserId",
column: x => x.UserId,
principalTable: "users_table",
principalColumn: "user_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "WorkExperiences",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
job_title = table.Column(type: "character varying(255)", maxLength: 255, nullable: false),
company_name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false),
Years = table.Column(type: "integer", nullable: false),
file_id = table.Column(type: "bigint", nullable: false),
description = table.Column(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkExperiences", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UserDegrees",
columns: table => new
{
DegreesId = table.Column(type: "bigint", nullable: false),
UserId = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserDegrees", x => new { x.DegreesId, x.UserId });
table.ForeignKey(
name: "FK_UserDegrees_Degrees_DegreesId",
column: x => x.DegreesId,
principalTable: "Degrees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserDegrees_users_table_UserId",
column: x => x.UserId,
principalTable: "users_table",
principalColumn: "user_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserCertifications",
columns: table => new
{
CertificationsId = table.Column(type: "bigint", nullable: false),
UserId = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserCertifications", x => new { x.CertificationsId, x.UserId });
table.ForeignKey(
name: "FK_UserCertifications_EmployeeCertifications_CertificationsId",
column: x => x.CertificationsId,
principalTable: "EmployeeCertifications",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserCertifications_users_table_UserId",
column: x => x.UserId,
principalTable: "users_table",
principalColumn: "user_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "UserWorkExperiences",
columns: table => new
{
UserId = table.Column(type: "bigint", nullable: false),
WorkExperiencesId = table.Column(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserWorkExperiences", x => new { x.UserId, x.WorkExperiencesId });
table.ForeignKey(
name: "FK_UserWorkExperiences_WorkExperiences_WorkExperiencesId",
column: x => x.WorkExperiencesId,
principalTable: "WorkExperiences",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UserWorkExperiences_users_table_UserId",
column: x => x.UserId,
principalTable: "users_table",
principalColumn: "user_id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_UserApplicationCategories_UserId",
table: "UserApplicationCategories",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserCertifications_UserId",
table: "UserCertifications",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserDegrees_UserId",
table: "UserDegrees",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserWorkExperiences_WorkExperiencesId",
table: "UserWorkExperiences",
column: "WorkExperiencesId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "UserApplicationCategories");
migrationBuilder.DropTable(
name: "UserCertifications");
migrationBuilder.DropTable(
name: "UserDegrees");
migrationBuilder.DropTable(
name: "UserWorkExperiences");
migrationBuilder.DropTable(
name: "EmployeeCertifications");
migrationBuilder.DropTable(
name: "Degrees");
migrationBuilder.DropTable(
name: "WorkExperiences");
migrationBuilder.DropColumn(
name: "code",
table: "users_table");
migrationBuilder.DropColumn(
name: "departement",
table: "users_table");
migrationBuilder.DropColumn(
name: "position",
table: "users_table");
}
}
}