using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace JobsMedical.Web.Migrations
{
    /// <inheritdoc />
    public partial class ShiftJobContacts : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<int>(
                name: "TalentListingId",
                table: "ContactMethods",
                type: "integer",
                nullable: true,
                oldClrType: typeof(int),
                oldType: "integer");

            migrationBuilder.AddColumn<int>(
                name: "JobOpeningId",
                table: "ContactMethods",
                type: "integer",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "ShiftId",
                table: "ContactMethods",
                type: "integer",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_ContactMethods_JobOpeningId",
                table: "ContactMethods",
                column: "JobOpeningId");

            migrationBuilder.CreateIndex(
                name: "IX_ContactMethods_ShiftId",
                table: "ContactMethods",
                column: "ShiftId");

            migrationBuilder.AddForeignKey(
                name: "FK_ContactMethods_JobOpenings_JobOpeningId",
                table: "ContactMethods",
                column: "JobOpeningId",
                principalTable: "JobOpenings",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ContactMethods_Shifts_ShiftId",
                table: "ContactMethods",
                column: "ShiftId",
                principalTable: "Shifts",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_ContactMethods_JobOpenings_JobOpeningId",
                table: "ContactMethods");

            migrationBuilder.DropForeignKey(
                name: "FK_ContactMethods_Shifts_ShiftId",
                table: "ContactMethods");

            migrationBuilder.DropIndex(
                name: "IX_ContactMethods_JobOpeningId",
                table: "ContactMethods");

            migrationBuilder.DropIndex(
                name: "IX_ContactMethods_ShiftId",
                table: "ContactMethods");

            migrationBuilder.DropColumn(
                name: "JobOpeningId",
                table: "ContactMethods");

            migrationBuilder.DropColumn(
                name: "ShiftId",
                table: "ContactMethods");

            migrationBuilder.AlterColumn<int>(
                name: "TalentListingId",
                table: "ContactMethods",
                type: "integer",
                nullable: false,
                defaultValue: 0,
                oldClrType: typeof(int),
                oldType: "integer",
                oldNullable: true);
        }
    }
}
