<?php

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

/**
 * PRC-1143 — konsolide şema: `workflows` tablosunun TAM tanımı (tek dosya).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::create('workflows', function (Blueprint $t) {
            $t->id();
            $t->string('name', 255);
            $t->text('description')->nullable();
            $t->string('trigger_event', 255);
            $t->boolean('is_active')->default(1);
            $t->integer('priority')->default(0);
            $t->unsignedInteger('execution_count')->default(0);
            $t->timestamp('last_executed_at')->nullable();
            $t->timestamp('created_at')->nullable();
            $t->timestamp('updated_at')->nullable();
            $t->index(['trigger_event', 'is_active'], 'workflows_trigger_event_is_active_index');
        });
    }

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