<?php

declare(strict_types=1);

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::table('users', function (Blueprint $table) {
            // Contact information
            $table->string('phone')->nullable()->after('email');
            $table->string('profile_picture')->nullable()->after('phone');

            // Address fields
            $table->string('address_line_1')->nullable()->after('timezone');
            $table->string('address_line_2')->nullable()->after('address_line_1');
            $table->string('city')->nullable()->after('address_line_2');
            $table->string('state')->nullable()->after('city');
            $table->string('country')->default('US')->after('state');
            $table->string('postal_code')->nullable()->after('country');

            // Phone verification
            $table->timestamp('phone_verified_at')->nullable()->after('email_verified_at');

            // Indexes for performance
            $table->index('phone');
        });
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropIndex(['phone']);
            $table->dropColumn([
                'phone',
                'profile_picture',
                'address_line_1',
                'address_line_2',
                'city',
                'state',
                'country',
                'postal_code',
                'phone_verified_at',
            ]);
        });
    }
};
