using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ClaudeDo.Data.Migrations
{
    /// <inheritdoc />
    public partial class AddPlanningPhaseAndBlockedBy : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "blocked_by_task_id",
                table: "tasks",
                type: "TEXT",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "planning_phase",
                table: "tasks",
                type: "TEXT",
                nullable: false,
                defaultValue: "none");

            migrationBuilder.UpdateData(
                table: "app_settings",
                keyColumn: "id",
                keyValue: 1,
                column: "default_permission_mode",
                value: "auto");

            migrationBuilder.CreateIndex(
                name: "idx_tasks_blocked_by",
                table: "tasks",
                column: "blocked_by_task_id");

            migrationBuilder.AddForeignKey(
                name: "FK_tasks_tasks_blocked_by_task_id",
                table: "tasks",
                column: "blocked_by_task_id",
                principalTable: "tasks",
                principalColumn: "id",
                onDelete: ReferentialAction.SetNull);
        }

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

            migrationBuilder.DropIndex(
                name: "idx_tasks_blocked_by",
                table: "tasks");

            migrationBuilder.DropColumn(
                name: "blocked_by_task_id",
                table: "tasks");

            migrationBuilder.DropColumn(
                name: "planning_phase",
                table: "tasks");

            migrationBuilder.UpdateData(
                table: "app_settings",
                keyColumn: "id",
                keyValue: 1,
                column: "default_permission_mode",
                value: "bypassPermissions");
        }
    }
}
