<?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
    {
        Schema::create('applicants', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
            $table->string('first_name', 100);
            $table->string('middle_name', 100)->nullable();
            $table->string('last_name', 100);
            $table->date('date_of_birth')->nullable();
            $table->string('gender', 30)->nullable();
            $table->string('nationality', 100)->nullable();
            $table->string('national_id', 60)->nullable();
            $table->string('passport_number', 60)->nullable();
            $table->string('marital_status', 30)->nullable();
            $table->string('disability_status', 120)->nullable();
            $table->text('disability_details')->nullable();
            $table->string('phone', 30)->nullable();
            $table->string('alternate_phone', 30)->nullable();
            $table->string('address')->nullable();
            $table->string('district', 100)->nullable();
            $table->string('country', 100)->default('Uganda');
            $table->string('postal_address', 120)->nullable();
            $table->string('guardian_name')->nullable();
            $table->string('guardian_relationship', 60)->nullable();
            $table->string('guardian_phone', 30)->nullable();
            $table->string('guardian_email', 190)->nullable();
            $table->string('photo_path')->nullable();
            $table->timestamps();

            $table->index(['last_name', 'first_name']);
            $table->index('national_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('applicants');
    }
};
