<?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->string('business_type'); // ice_cream | restaurant | retail | cafe
            $table->unsignedBigInteger('owner_id')->nullable(); // FK added after users table
            $table->json('enabled_modules')->nullable();        // ['orders','products','production',...]
            $table->json('settings')->nullable();               // {currency, timezone, tax_rate, ...}
            $table->string('subscription_plan')->default('free'); // free | basic | pro
            $table->boolean('is_active')->default(true);
            $table->timestamps();
            $table->softDeletes();
        });
    }

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