using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
    /// <inheritdoc />
    public partial class Addtablegoverment : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_CMSAgencys_CMSCandidates_CMSCandidateId",
                table: "CMSAgencys");

            migrationBuilder.DropForeignKey(
                name: "FK_CMSAgencys_Candidates_CandidateId",
                table: "CMSAgencys");

            migrationBuilder.DropForeignKey(
                name: "FK_CMSGovernments_CMSCandidates_CMSCandidateId",
                table: "CMSGovernments");

            migrationBuilder.DropForeignKey(
                name: "FK_CMSGovernments_Candidates_CandidateId",
                table: "CMSGovernments");

            migrationBuilder.DropIndex(
                name: "IX_CMSGovernments_CandidateId",
                table: "CMSGovernments");

            migrationBuilder.DropIndex(
                name: "IX_CMSAgencys_CandidateId",
                table: "CMSAgencys");

            migrationBuilder.DropColumn(
                name: "CandidateId",
                table: "CMSGovernments");

            migrationBuilder.DropColumn(
                name: "CandidateId",
                table: "CMSAgencys");

            migrationBuilder.AlterColumn<Guid>(
                name: "CMSCandidateId",
                table: "CMSGovernments",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)",
                oldNullable: true)
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AlterColumn<Guid>(
                name: "CMSCandidateId",
                table: "CMSAgencys",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)",
                oldNullable: true)
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AddForeignKey(
                name: "FK_CMSAgencys_CMSCandidates_CMSCandidateId",
                table: "CMSAgencys",
                column: "CMSCandidateId",
                principalTable: "CMSCandidates",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_CMSGovernments_CMSCandidates_CMSCandidateId",
                table: "CMSGovernments",
                column: "CMSCandidateId",
                principalTable: "CMSCandidates",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

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

            migrationBuilder.DropForeignKey(
                name: "FK_CMSGovernments_CMSCandidates_CMSCandidateId",
                table: "CMSGovernments");

            migrationBuilder.AlterColumn<Guid>(
                name: "CMSCandidateId",
                table: "CMSGovernments",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "CandidateId",
                table: "CMSGovernments",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci");

            migrationBuilder.AlterColumn<Guid>(
                name: "CMSCandidateId",
                table: "CMSAgencys",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "CandidateId",
                table: "CMSAgencys",
                type: "char(36)",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
                collation: "ascii_general_ci");

            migrationBuilder.CreateIndex(
                name: "IX_CMSGovernments_CandidateId",
                table: "CMSGovernments",
                column: "CandidateId");

            migrationBuilder.CreateIndex(
                name: "IX_CMSAgencys_CandidateId",
                table: "CMSAgencys",
                column: "CandidateId");

            migrationBuilder.AddForeignKey(
                name: "FK_CMSAgencys_CMSCandidates_CMSCandidateId",
                table: "CMSAgencys",
                column: "CMSCandidateId",
                principalTable: "CMSCandidates",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_CMSAgencys_Candidates_CandidateId",
                table: "CMSAgencys",
                column: "CandidateId",
                principalTable: "Candidates",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_CMSGovernments_CMSCandidates_CMSCandidateId",
                table: "CMSGovernments",
                column: "CMSCandidateId",
                principalTable: "CMSCandidates",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_CMSGovernments_Candidates_CandidateId",
                table: "CMSGovernments",
                column: "CandidateId",
                principalTable: "Candidates",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
