using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

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

            migrationBuilder.AddColumn<DateTime>(
                name: "planning_finalized_at",
                table: "tasks",
                type: "TEXT",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "planning_session_id",
                table: "tasks",
                type: "TEXT",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "planning_session_token",
                table: "tasks",
                type: "TEXT",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "idx_tasks_parent_task_id",
                table: "tasks",
                column: "parent_task_id");

            migrationBuilder.AddForeignKey(
                name: "FK_tasks_tasks_parent_task_id",
                table: "tasks",
                column: "parent_task_id",
                principalTable: "tasks",
                principalColumn: "id",
                onDelete: ReferentialAction.Restrict);
        }

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

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

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

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

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

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