using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PARR.DAL.Migrations
{
    /// <inheritdoc />
    public partial class tblRobotsRename : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_RobotHistories_RobotConfigurations_RobotConfigurationId",
                schema: "robot",
                table: "RobotHistories");

            migrationBuilder.DropForeignKey(
                name: "FK_RobotHistories_RobotHistoryLevels_HistoryLevel",
                schema: "robot",
                table: "RobotHistories");

            migrationBuilder.DropForeignKey(
                name: "FK_RobotHistories_TaskStatuses_TaskStatusCode",
                schema: "robot",
                table: "RobotHistories");

            migrationBuilder.DropPrimaryKey(
                name: "PK_RobotHistoryLevels",
                schema: "robot",
                table: "RobotHistoryLevels");

            migrationBuilder.DropPrimaryKey(
                name: "PK_RobotHistories",
                schema: "robot",
                table: "RobotHistories");

            migrationBuilder.RenameTable(
                name: "RobotHistoryLevels",
                schema: "robot",
                newName: "HistoryLevels",
                newSchema: "robot");

            migrationBuilder.RenameTable(
                name: "RobotHistories",
                schema: "robot",
                newName: "Histories",
                newSchema: "robot");

            migrationBuilder.RenameIndex(
                name: "IX_RobotHistories_TaskStatusCode",
                schema: "robot",
                table: "Histories",
                newName: "IX_Histories_TaskStatusCode");

            migrationBuilder.RenameIndex(
                name: "IX_RobotHistories_RobotConfigurationId_DateCreated",
                schema: "robot",
                table: "Histories",
                newName: "IX_Histories_RobotConfigurationId_DateCreated");

            migrationBuilder.RenameIndex(
                name: "IX_RobotHistories_HistoryLevel_DateCreated",
                schema: "robot",
                table: "Histories",
                newName: "IX_Histories_HistoryLevel_DateCreated");

            migrationBuilder.RenameIndex(
                name: "IX_RobotHistories_DateCreated",
                schema: "robot",
                table: "Histories",
                newName: "IX_Histories_DateCreated");

            migrationBuilder.AddPrimaryKey(
                name: "PK_HistoryLevels",
                schema: "robot",
                table: "HistoryLevels",
                column: "Level");

            migrationBuilder.AddPrimaryKey(
                name: "PK_Histories",
                schema: "robot",
                table: "Histories",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Histories_HistoryLevels_HistoryLevel",
                schema: "robot",
                table: "Histories",
                column: "HistoryLevel",
                principalSchema: "robot",
                principalTable: "HistoryLevels",
                principalColumn: "Level",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Histories_RobotConfigurations_RobotConfigurationId",
                schema: "robot",
                table: "Histories",
                column: "RobotConfigurationId",
                principalTable: "RobotConfigurations",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_Histories_TaskStatuses_TaskStatusCode",
                schema: "robot",
                table: "Histories",
                column: "TaskStatusCode",
                principalSchema: "robot",
                principalTable: "TaskStatuses",
                principalColumn: "Code",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Histories_HistoryLevels_HistoryLevel",
                schema: "robot",
                table: "Histories");

            migrationBuilder.DropForeignKey(
                name: "FK_Histories_RobotConfigurations_RobotConfigurationId",
                schema: "robot",
                table: "Histories");

            migrationBuilder.DropForeignKey(
                name: "FK_Histories_TaskStatuses_TaskStatusCode",
                schema: "robot",
                table: "Histories");

            migrationBuilder.DropPrimaryKey(
                name: "PK_HistoryLevels",
                schema: "robot",
                table: "HistoryLevels");

            migrationBuilder.DropPrimaryKey(
                name: "PK_Histories",
                schema: "robot",
                table: "Histories");

            migrationBuilder.RenameTable(
                name: "HistoryLevels",
                schema: "robot",
                newName: "RobotHistoryLevels",
                newSchema: "robot");

            migrationBuilder.RenameTable(
                name: "Histories",
                schema: "robot",
                newName: "RobotHistories",
                newSchema: "robot");

            migrationBuilder.RenameIndex(
                name: "IX_Histories_TaskStatusCode",
                schema: "robot",
                table: "RobotHistories",
                newName: "IX_RobotHistories_TaskStatusCode");

            migrationBuilder.RenameIndex(
                name: "IX_Histories_RobotConfigurationId_DateCreated",
                schema: "robot",
                table: "RobotHistories",
                newName: "IX_RobotHistories_RobotConfigurationId_DateCreated");

            migrationBuilder.RenameIndex(
                name: "IX_Histories_HistoryLevel_DateCreated",
                schema: "robot",
                table: "RobotHistories",
                newName: "IX_RobotHistories_HistoryLevel_DateCreated");

            migrationBuilder.RenameIndex(
                name: "IX_Histories_DateCreated",
                schema: "robot",
                table: "RobotHistories",
                newName: "IX_RobotHistories_DateCreated");

            migrationBuilder.AddPrimaryKey(
                name: "PK_RobotHistoryLevels",
                schema: "robot",
                table: "RobotHistoryLevels",
                column: "Level");

            migrationBuilder.AddPrimaryKey(
                name: "PK_RobotHistories",
                schema: "robot",
                table: "RobotHistories",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_RobotHistories_RobotConfigurations_RobotConfigurationId",
                schema: "robot",
                table: "RobotHistories",
                column: "RobotConfigurationId",
                principalTable: "RobotConfigurations",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_RobotHistories_RobotHistoryLevels_HistoryLevel",
                schema: "robot",
                table: "RobotHistories",
                column: "HistoryLevel",
                principalSchema: "robot",
                principalTable: "RobotHistoryLevels",
                principalColumn: "Level",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_RobotHistories_TaskStatuses_TaskStatusCode",
                schema: "robot",
                table: "RobotHistories",
                column: "TaskStatusCode",
                principalSchema: "robot",
                principalTable: "TaskStatuses",
                principalColumn: "Code",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
