<?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('customers', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('phone')->index();
            $table->string('national_id')->nullable()->index();
            $table->text('address')->nullable();
            $table->string('email')->nullable();
            $table->string('customer_type', 20)->default('individual')->index();
            $table->foreignId('main_account_id')->nullable()->constrained('main_accounts')->nullOnDelete();
            $table->foreignId('sub_account_id')->nullable()->constrained('sub_accounts')->nullOnDelete();
            $table->text('notes')->nullable();
            $table->string('status', 20)->default('active')->index();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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