<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            try {
                DB::statement("ALTER TABLE users MODIFY COLUMN role VARCHAR(50) NOT NULL DEFAULT 'waiter'");
            } catch (\Exception $e) {
                try {
                    $table->string('role', 50)->default('waiter')->change();
                } catch (\Exception $e2) {
                }
            }
        });
    }

    public function down(): void
    {
    }
};
