using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SolutionErp.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddIsUserSelectableToApprovalWorkflows : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<bool>(
                name: "IsUserSelectable",
                table: "ApprovalWorkflows",
                type: "bit",
                nullable: false,
                defaultValue: false);

            // Backfill: workflow đang active = auto user-selectable (giữ behavior
            // hiện tại — Workspace dropdown vẫn hiện active workflow). Archived
            // versions default false, admin tự toggle khi muốn user pick.
            migrationBuilder.Sql("UPDATE ApprovalWorkflows SET IsUserSelectable = 1 WHERE IsActive = 1;");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "IsUserSelectable",
                table: "ApprovalWorkflows");
        }
    }
}
