<?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
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // For MySQL, we need to modify the ENUM type to add new roles
        if (DB::getDriverName() === 'mysql') {
            DB::statement("ALTER TABLE `users` MODIFY COLUMN `role` ENUM('admin', 'manager', 'staff', 'pos_staff', 'pos_manager', 'restaurant_owner', 'branch_manager') DEFAULT 'staff'");
        } else {
            // For other databases, change to string
            Schema::table('users', function (Blueprint $table) {
                $table->string('role', 50)->default('staff')->change();
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (DB::getDriverName() === 'mysql') {
            DB::statement("ALTER TABLE `users` MODIFY COLUMN `role` ENUM('admin', 'manager', 'staff', 'pos_staff', 'pos_manager') DEFAULT 'staff'");
        } else {
            Schema::table('users', function (Blueprint $table) {
                $table->enum('role', ['admin', 'manager', 'staff', 'pos_staff', 'pos_manager'])->default('staff')->change();
            });
        }
    }
};
