using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SolutionErp.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    // Mig 31 (S23 t1 Plan K Chunk A) — F2 storage swap Users → ApprovalWorkflowLevels.
    // Manual reorder Up(): ADD col first → DROP col second (per memory rule
    // feedback_ef_migration_backfill_reorder.md). NO BACKFILL block — Option A bro
    // accept 4 prod user (fin.pp + pm.nv + nv.test + truong.nguyen) lose value cũ
    // AllowDrafterSkipToFinal=true. Admin re-config qua Workflow Designer per slot.
    //
    // Down() reverse order với data loss accepted: cờ AllowApproverSkipToFinal sẽ
    // mất khi rollback (Users.AllowDrafterSkipToFinal restore default false).
    public partial class RefactorSkipToFinalToApproverLevel : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // Step 1 — ADD new column on ApprovalWorkflowLevels (per-slot Approver scope).
            migrationBuilder.AddColumn<bool>(
                name: "AllowApproverSkipToFinal",
                table: "ApprovalWorkflowLevels",
                type: "bit",
                nullable: false,
                defaultValue: false);

            // Step 2 — DROP old column on Users (NO BACKFILL — Option A accept lose).
            migrationBuilder.DropColumn(
                name: "AllowDrafterSkipToFinal",
                table: "Users");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            // Step 1 — DROP new column on ApprovalWorkflowLevels.
            migrationBuilder.DropColumn(
                name: "AllowApproverSkipToFinal",
                table: "ApprovalWorkflowLevels");

            // Step 2 — ADD old column on Users (data loss accepted — default false).
            migrationBuilder.AddColumn<bool>(
                name: "AllowDrafterSkipToFinal",
                table: "Users",
                type: "bit",
                nullable: false,
                defaultValue: false);
        }
    }
}
