<?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('currencies', function (Blueprint $table) {
            $table->id();
            $table->foreignId('agency_id')->constrained('agencies')->onDelete('cascade');
            $table->string('code', 3);
            $table->string('symbol', 5);
            $table->decimal('exchange_rate', 15, 6)->default(1.000000);
            $table->boolean('is_active')->default(true);
            $table->boolean('is_base')->default(false);
            $table->timestamps();

            $table->unique(['agency_id', 'code']);
        });
    }

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