<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('report_filters', function (Blueprint $table) {
            $table->id();
            $table->foreignId('report_id')->constrained()->cascadeOnDelete();
            $table->string('key', 100);
            $table->string('label');
            $table->string('type', 50);
            $table->boolean('nullable')->default(true);
            $table->text('default_value')->nullable();
            $table->json('options')->nullable();
            $table->string('data_source')->nullable();
            $table->integer('order')->default(0);
            $table->timestamps();
            
            $table->index(['report_id', 'order']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('report_filters');
    }
};
