<?php

declare(strict_types=1);

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::create('ticket_custom_fields', function (Blueprint $table): void {
            $table->id();
            $table->string('name');
            $table->enum('type', ['text', 'select', 'checkbox', 'number']);
            $table->json('options')->nullable();
            $table->boolean('is_required')->default(false);
            $table->foreignId('department_id')->nullable()->constrained('departments')->nullOnDelete();
            $table->integer('sort_order')->default(0);
            $table->timestamps();
        });
    }

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