<?php

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('categorias', function (Blueprint $table) {
            $table->id();
            $table->foreignId('departamento_id')->constrained('departamentos')->cascadeOnDelete();
            $table->string('nome');
            $table->string('slug');
            $table->text('descricao')->nullable();
            $table->string('cor')->default('primary');
            $table->boolean('ativo')->default(true);
            $table->timestamps();

            $table->unique(['departamento_id', 'slug']);
        });
    }

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