using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class updatetableorgaddorgagency1 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Organizations_OrganizationAgencys_OrganizationAgencyId",
                table: "Organizations");

            migrationBuilder.DropForeignKey(
                name: "FK_Organizations_OrganizationGovernmentAgencys_OrganizationGove~",
                table: "Organizations");

            migrationBuilder.DropIndex(
                name: "IX_Organizations_OrganizationAgencyId",
                table: "Organizations");

            migrationBuilder.DropIndex(
                name: "IX_Organizations_OrganizationGovernmentAgencyId",
                table: "Organizations");

            migrationBuilder.DropColumn(
                name: "OrganizationAgencyId",
                table: "Organizations");

            migrationBuilder.DropColumn(
                name: "OrganizationGovernmentAgencyId",
                table: "Organizations");

            migrationBuilder.AddColumn<Guid>(
                name: "OrganizationAgency",
                table: "Organizations",
                type: "char(36)",
                nullable: true,
                comment: "OrganizationAgencyId",
                collation: "ascii_general_ci")
                .Annotation("Relational:ColumnOrder", 10);

            migrationBuilder.AddColumn<Guid>(
                name: "OrganizationGovernmentAgency",
                table: "Organizations",
                type: "char(36)",
                nullable: true,
                comment: "OrganizationGovernmentAgencyId",
                collation: "ascii_general_ci")
                .Annotation("Relational:ColumnOrder", 11);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "OrganizationAgency",
                table: "Organizations");

            migrationBuilder.DropColumn(
                name: "OrganizationGovernmentAgency",
                table: "Organizations");

            migrationBuilder.AddColumn<Guid>(
                name: "OrganizationAgencyId",
                table: "Organizations",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.AddColumn<Guid>(
                name: "OrganizationGovernmentAgencyId",
                table: "Organizations",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci");

            migrationBuilder.CreateIndex(
                name: "IX_Organizations_OrganizationAgencyId",
                table: "Organizations",
                column: "OrganizationAgencyId");

            migrationBuilder.CreateIndex(
                name: "IX_Organizations_OrganizationGovernmentAgencyId",
                table: "Organizations",
                column: "OrganizationGovernmentAgencyId");

            migrationBuilder.AddForeignKey(
                name: "FK_Organizations_OrganizationAgencys_OrganizationAgencyId",
                table: "Organizations",
                column: "OrganizationAgencyId",
                principalTable: "OrganizationAgencys",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Organizations_OrganizationGovernmentAgencys_OrganizationGove~",
                table: "Organizations",
                column: "OrganizationGovernmentAgencyId",
                principalTable: "OrganizationGovernmentAgencys",
                principalColumn: "Id");
        }
    }
}
