<?php

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

return new class extends Migration {
    public function up()
    {
        Schema::table('workflow_tasks', function (Blueprint $table) {
            $table->unsignedBigInteger('workflow_id')->nullable()->after('instance_id');
            $table->foreign('workflow_id')->references('id')->on('workflows')->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::table('workflow_tasks', function (Blueprint $table) {
            $table->dropForeign(['workflow_id']);
            $table->dropColumn('workflow_id');
        });
    }
};
