<?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('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('username')->unique();
            $table->string('password');
            $table->string('mobile', 15)->nullable()->index();
            $table->text('address')->nullable();
            $table->text('notes')->nullable();
            $table->json('bank_accounts')->nullable();
            $table->boolean('is_active')->default(true)->index();
            $table->boolean('is_customer')->default(false)->index();
            $table->rememberToken();
            $table->timestamps();
            $table->softDeletes();

            // Composite index for customer queries
            $table->index(['is_customer', 'is_active']);
        });
    }

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