using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

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

            migrationBuilder.DropForeignKey(
                name: "FK_InsigniaRequestProfiles_Profiles_ProfileId",
                table: "InsigniaRequestProfiles");

            migrationBuilder.DropForeignKey(
                name: "FK_InsigniaRequests_Organizations_OrganizationId",
                table: "InsigniaRequests");

            migrationBuilder.DropForeignKey(
                name: "FK_ProfileInsignias_Profiles_ProfileId",
                table: "ProfileInsignias");

            migrationBuilder.DropIndex(
                name: "IX_InsigniaRequests_OrganizationId",
                table: "InsigniaRequests");

            migrationBuilder.DropIndex(
                name: "IX_InsigniaRequestProfiles_ProfileId",
                table: "InsigniaRequestProfiles");

            migrationBuilder.DropIndex(
                name: "IX_InsigniaNoteProfiles_ProfileId",
                table: "InsigniaNoteProfiles");

            migrationBuilder.AlterColumn<Guid>(
                name: "ProfileId",
                table: "ProfileInsignias",
                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: "ProfileId",
                table: "InsigniaNoteProfiles",
                type: "char(36)",
                nullable: true,
                collation: "ascii_general_ci",
                oldClrType: typeof(Guid),
                oldType: "char(36)")
                .OldAnnotation("Relational:Collation", "ascii_general_ci");

            migrationBuilder.AddForeignKey(
                name: "FK_ProfileInsignias_Profiles_ProfileId",
                table: "ProfileInsignias",
                column: "ProfileId",
                principalTable: "Profiles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

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

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

            migrationBuilder.AlterColumn<Guid>(
                name: "ProfileId",
                table: "InsigniaNoteProfiles",
                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.CreateIndex(
                name: "IX_InsigniaRequests_OrganizationId",
                table: "InsigniaRequests",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_InsigniaRequestProfiles_ProfileId",
                table: "InsigniaRequestProfiles",
                column: "ProfileId");

            migrationBuilder.CreateIndex(
                name: "IX_InsigniaNoteProfiles_ProfileId",
                table: "InsigniaNoteProfiles",
                column: "ProfileId");

            migrationBuilder.AddForeignKey(
                name: "FK_InsigniaNoteProfiles_Profiles_ProfileId",
                table: "InsigniaNoteProfiles",
                column: "ProfileId",
                principalTable: "Profiles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InsigniaRequestProfiles_Profiles_ProfileId",
                table: "InsigniaRequestProfiles",
                column: "ProfileId",
                principalTable: "Profiles",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_InsigniaRequests_Organizations_OrganizationId",
                table: "InsigniaRequests",
                column: "OrganizationId",
                principalTable: "Organizations",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ProfileInsignias_Profiles_ProfileId",
                table: "ProfileInsignias",
                column: "ProfileId",
                principalTable: "Profiles",
                principalColumn: "Id");
        }
    }
}
