<?php

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

class AddMasaAktifColumnToUsersTable extends Migration
{
    public function up()
    {
        // Cek apakah kolom masa_aktif sudah ada
        if (!Schema::hasColumn('users', 'masa_aktif')) {
            Schema::table('users', function (Blueprint $table) {
                $table->date('masa_aktif')->nullable()->after('kampus');
            });
        }
    }

    public function down()
    {
        // Cek apakah kolom masa_aktif ada sebelum dihapus
        if (Schema::hasColumn('users', 'masa_aktif')) {
            Schema::table('users', function (Blueprint $table) {
                $table->dropColumn('masa_aktif');
            });
        }
    }
}