using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SolutionErp.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AlterPeDeptApprovalsUniqueFilteredForInnerSteps : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "UX_PEDeptApprovals_PE_Phase_Dept_Stage",
                table: "PurchaseEvaluationDepartmentApprovals");

            migrationBuilder.CreateIndex(
                name: "UX_PEDeptApprovals_PE_Phase_Dept_Stage",
                table: "PurchaseEvaluationDepartmentApprovals",
                columns: new[] { "PurchaseEvaluationId", "PhaseAtApproval", "DepartmentId", "Stage" },
                unique: true,
                filter: "[InnerStepId] IS NULL");

            migrationBuilder.CreateIndex(
                name: "UX_PEDeptApprovals_PE_Phase_InnerStep",
                table: "PurchaseEvaluationDepartmentApprovals",
                columns: new[] { "PurchaseEvaluationId", "PhaseAtApproval", "InnerStepId" },
                unique: true,
                filter: "[InnerStepId] IS NOT NULL");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropIndex(
                name: "UX_PEDeptApprovals_PE_Phase_Dept_Stage",
                table: "PurchaseEvaluationDepartmentApprovals");

            migrationBuilder.DropIndex(
                name: "UX_PEDeptApprovals_PE_Phase_InnerStep",
                table: "PurchaseEvaluationDepartmentApprovals");

            migrationBuilder.CreateIndex(
                name: "UX_PEDeptApprovals_PE_Phase_Dept_Stage",
                table: "PurchaseEvaluationDepartmentApprovals",
                columns: new[] { "PurchaseEvaluationId", "PhaseAtApproval", "DepartmentId", "Stage" },
                unique: true);
        }
    }
}
