<?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::table('users', function (Blueprint $table) {
            // Check if column doesn't exist before adding to prevent errors
            if (!Schema::hasColumn('users', 'role')) {
                $table->enum('role', ['user', 'admin', 'agency'])->default('user')->after('password');
                $table->string('phone')->nullable()->after('role');
                $table->string('fcm_token')->nullable()->after('phone');
            }
        });
    }

    public function down(): void {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn(['role', 'phone', 'fcm_token']);
        });
    }
};
