<?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('phone', 20)->unique();
            $table->string('email', 100)->nullable()->unique();
            $table->string('business_name');
            $table->string('business_slug', 50)->unique();
            $table->string('business_category')->nullable();
            $table->text('password_hash');
            $table->text('auth_token')->nullable();
            $table->enum('subscription_status', ['trial', 'trial_expired', 'pending', 'active', 'expired', 'suspended'])->default('trial');
            $table->unsignedBigInteger('plan_id')->nullable();
            $table->timestamp('subscription_expires_at')->nullable();
            $table->timestamp('trial_ends_at')->nullable();
            $table->boolean('subdomain_locked')->default(false);
            $table->timestamps();
        });
    }

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