<?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('tenants', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('slug')->unique();
            $table->text('description')->nullable();
            $table->string('logo_url', 500)->nullable();
            $table->string('website_url', 255)->nullable();
            $table->string('support_email', 255)->nullable();
            $table->string('support_phone', 20)->nullable();
            $table->enum('status', ['active', 'inactive', 'suspended', 'trial', 'premium'])
                ->default('trial');
            $table->string('subscription_plan', 100)->nullable();
            $table->enum('subscription_status', ['active', 'inactive', 'expired', 'canceled'])
                ->default('active');
            $table->date('subscription_end_date')->nullable();
            $table->boolean('is_white_label')->default(false);
            $table->string('theme_color', 7)->nullable();
            $table->string('custom_domain', 255)->nullable();
            $table->integer('api_limit_per_hour')->default(10000);
            $table->integer('max_users')->default(100);
            $table->timestamps();
            $table->softDeletes();
            
            $table->index('slug');
            $table->index('status');
            $table->index('created_at');
        });
    }

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