<?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
    {
        // Siswa
        if (!Schema::hasColumn('siswas', 'remember_token')) {
            Schema::table('siswas', function (Blueprint $table) {
                $table->rememberToken();
            });
        }

        // Guru
        if (!Schema::hasColumn('gurus', 'remember_token')) {
            Schema::table('gurus', function (Blueprint $table) {
                $table->rememberToken();
            });
        }

        // Admin
        if (!Schema::hasColumn('admins', 'remember_token')) {
            Schema::table('admins', function (Blueprint $table) {
                $table->rememberToken();
            });
        }
    }

    public function down(): void
    {
        Schema::table('siswas', function (Blueprint $table) {
            $table->dropColumn('remember_token');
        });

        Schema::table('gurus', function (Blueprint $table) {
            $table->dropColumn('remember_token');
        });

        Schema::table('admins', function (Blueprint $table) {
            $table->dropColumn('remember_token');
        });
    }
};