<?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('cash_movement_reasons', function (Blueprint $table) {
            $table->id();
            // No DB-level FK on tenant_id (integrity comes from BelongsToTenant +
            // TenantScope), matching every other owned table in this app.
            $table->unsignedBigInteger('tenant_id')->nullable()->index();
            $table->string('code', 30);
            $table->string('name', 100);
            $table->boolean('requires_note')->default(false);
            $table->unsignedInteger('sort_order')->default(0);
            $table->boolean('is_active')->default(true);
            $table->timestamps();
            $table->unique(['tenant_id', 'code']);
        });
    }

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