<?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::create('workflow_transitions', function (Blueprint $table) {
            $table->id();
            $table->foreignId('workflow_id')->constrained('workflows')->onDelete('cascade');
            $table->foreignId('from_step_id')->constrained('workflow_steps')->onDelete('cascade');
            $table->foreignId('to_step_id')->constrained('workflow_steps')->onDelete('cascade');
            $table->string('name');
            $table->json('role_ids')->nullable();
            $table->json('user_ids')->nullable();
            $table->boolean('require_comments')->default(false);
            $table->boolean('require_file')->default(false);
            $table->text('comments')->nullable();
            $table->string('file_path')->nullable();
            $table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists('workflow_transitions');
    }
};
