<?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('academies', function (Blueprint $table) {
            $table->id();
            $table->uuid('uuid')->unique();
            $table->string('name');
            $table->string('name_ar')->nullable();
            $table->string('slug')->unique();
            $table->string('email')->nullable();
            $table->string('phone')->nullable();
            $table->string('logo_path')->nullable();
            $table->string('currency', 3)->default('EGP');
            $table->string('timezone')->default('Africa/Cairo');
            $table->string('locale', 5)->default('ar');
            $table->jsonb('settings')->default('{}');
            $table->string('status', 20)->default('active');
            $table->timestamps();
            $table->softDeletes();

            $table->index('status');
        });

        DB::statement("ALTER TABLE academies ADD CONSTRAINT academies_status_check CHECK (status IN ('active', 'suspended', 'trial', 'cancelled'))");
    }

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