<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            // Professional information
            $table->string('position')->nullable()->after('department');
            $table->decimal('salary', 10, 2)->nullable()->after('hire_date');
            
            // Personal information
            $table->string('emergency_contact_name')->nullable()->after('emergency_contact');
            $table->string('emergency_contact_phone')->nullable()->after('emergency_contact_name');
            $table->text('address')->nullable()->after('emergency_contact_phone');
            $table->date('date_of_birth')->nullable()->after('address');
            $table->string('national_id')->nullable()->after('date_of_birth');
            
            // System tracking
            $table->timestamp('last_login_at')->nullable()->after('updated_at');
            
            // Remove old emergency_contact field if it exists
            // $table->dropColumn('emergency_contact'); // Uncomment if needed
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn([
                'position',
                'salary',
                'emergency_contact_name',
                'emergency_contact_phone',
                'address',
                'date_of_birth',
                'national_id',
                'last_login_at',
            ]);
        });
    }
};
