<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('tasks', function (Blueprint $table) {
            if (! Schema::hasColumn('tasks', 'blocker_type')) {
                $table->string('blocker_type')->nullable()->after('status');
            }
            if (! Schema::hasColumn('tasks', 'blocker_note')) {
                $table->text('blocker_note')->nullable()->after('blocker_type');
            }
        });
    }

    public function down(): void
    {
        Schema::table('tasks', function (Blueprint $table) {
            if (Schema::hasColumn('tasks', 'blocker_note')) {
                $table->dropColumn('blocker_note');
            }
            if (Schema::hasColumn('tasks', 'blocker_type')) {
                $table->dropColumn('blocker_type');
            }
        });
    }
};
