<?php

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

class AddUserIdToAdminsTable extends Migration
{
    public function up()
    {
        Schema::table('admins', function (Blueprint $table) {
            $table->uuid('user_id')->after('id'); // Add the user_id column as UUID

            // Add the foreign key constraint
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }

    public function down()
    {
        Schema::table('admins', function (Blueprint $table) {
            // Drop the foreign key first
            $table->dropForeign(['user_id']);
            $table->dropColumn('user_id');
        });
    }
}
