using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

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

            migrationBuilder.DropForeignKey(
                name: "FK_BaseCommand_CommandTypes_CommandTypeId",
                table: "BaseCommand");

            migrationBuilder.DropForeignKey(
                name: "FK_CommandDocuments_BaseCommand_CommandId",
                table: "CommandDocuments");

            migrationBuilder.DropPrimaryKey(
                name: "PK_BaseCommand",
                table: "BaseCommand");

            migrationBuilder.RenameTable(
                name: "BaseCommand",
                newName: "Command");

            migrationBuilder.RenameIndex(
                name: "IX_BaseCommand_CommandTypeId",
                table: "Command",
                newName: "IX_Command_CommandTypeId");

            migrationBuilder.RenameIndex(
                name: "IX_BaseCommand_CommandStatusId",
                table: "Command",
                newName: "IX_Command_CommandStatusId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Command",
                table: "Command",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Command_CommandStatuses_CommandStatusId",
                table: "Command",
                column: "CommandStatusId",
                principalTable: "CommandStatuses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Command_CommandTypes_CommandTypeId",
                table: "Command",
                column: "CommandTypeId",
                principalTable: "CommandTypes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_CommandDocuments_Command_CommandId",
                table: "CommandDocuments",
                column: "CommandId",
                principalTable: "Command",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

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

            migrationBuilder.DropForeignKey(
                name: "FK_Command_CommandTypes_CommandTypeId",
                table: "Command");

            migrationBuilder.DropForeignKey(
                name: "FK_CommandDocuments_Command_CommandId",
                table: "CommandDocuments");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Command",
                table: "Command");

            migrationBuilder.RenameTable(
                name: "Command",
                newName: "BaseCommand");

            migrationBuilder.RenameIndex(
                name: "IX_Command_CommandTypeId",
                table: "BaseCommand",
                newName: "IX_BaseCommand_CommandTypeId");

            migrationBuilder.RenameIndex(
                name: "IX_Command_CommandStatusId",
                table: "BaseCommand",
                newName: "IX_BaseCommand_CommandStatusId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_BaseCommand",
                table: "BaseCommand",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_BaseCommand_CommandStatuses_CommandStatusId",
                table: "BaseCommand",
                column: "CommandStatusId",
                principalTable: "CommandStatuses",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_BaseCommand_CommandTypes_CommandTypeId",
                table: "BaseCommand",
                column: "CommandTypeId",
                principalTable: "CommandTypes",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_CommandDocuments_BaseCommand_CommandId",
                table: "CommandDocuments",
                column: "CommandId",
                principalTable: "BaseCommand",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
