<?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('companies', function (Blueprint $table) {
            $table->id();
            
            // Core Identity
            $table->string('name');
            $table->string('email')->nullable();
            $table->string('phone')->nullable();
            
            // Accounting & Localization
            $table->string('tax_number')->nullable()->comment('TPIN or VAT registration number');
            $table->string('currency', 3)->default('ZMW')->comment('ISO 4217 Currency Code');
            $table->string('timezone')->default('Africa/Lusaka'); // Added Timezone
            
            // Physical Presence
            $table->text('address')->nullable();
            
            // Ownership
            $table->foreignId('owner_id')
                  ->constrained('users')
                  ->onDelete('cascade');

            $table->timestamps();
            
            $table->index('owner_id');
        });
    }

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