<?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
    {
        if (!Schema::hasColumn('siswas', 'foto_profil')) {
            Schema::table('siswas', function (Blueprint $table) {
                $table->string('foto_profil')->nullable()->after('password');
            });
        }

        if (!Schema::hasColumn('gurus', 'foto_profil')) {
            Schema::table('gurus', function (Blueprint $table) {
                $table->string('foto_profil')->nullable()->after('password');
            });
        }

        if (!Schema::hasColumn('admins', 'foto_profil')) {
            Schema::table('admins', function (Blueprint $table) {
                $table->string('foto_profil')->nullable()->after('password');
            });
        }
    }

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