<?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->char('code', 3)->unique();
            $table->string('name_ar');
            $table->string('name_en');
            $table->string('symbol', 8);
            $table->unsignedTinyInteger('minor_unit')->default(2);
            $table->string('symbol_position')->default('after');
            $table->decimal('exchange_rate', 18, 8)->default(1);
            $table->timestamp('rate_updated_at')->nullable();
            $table->unsignedInteger('min_payment_minor')->default(0);
            $table->unsignedBigInteger('max_payment_minor')->default(100000000);
            $table->boolean('is_base')->default(false)->index();
            $table->boolean('is_active')->default(true)->index();
            $table->timestamps();
        });
    }

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