<?php

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

class CreateMilitaryPersonnelTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('military_personnel', function (Blueprint $table) {
            $table->id();
            $table->string('service_number')->unique();
            $table->string('first_name');
            $table->string('middle_name')->nullable();
            $table->string('last_name');
            $table->string('email')->unique();
            $table->string('phone');
            $table->date('date_of_birth');
            $table->string('blood_type');
            $table->enum('marital_status', ['Single', 'Married', 'Divorced', 'Widowed']);
            $table->integer('dependents')->default(0);
            $table->string('ssn_last_four'); // Last 4 digits for security

            // Military Information
            $table->string('rank');
            $table->string('pay_grade');
            $table->string('mos'); // Military Occupational Specialty
            $table->string('unit');
            $table->string('squad_size')->nullable();
            $table->date('enlistment_date');
            $table->date('ets_date'); // End of Term of Service
            $table->integer('years_of_service');
            $table->enum('status', ['Active Duty', 'Reserve', 'National Guard', 'Retired', 'Separated']);
            $table->string('security_clearance');

            // Assignment Information
            $table->string('current_base');
            $table->string('current_deployment')->nullable();
            $table->date('deployment_return_date')->nullable();
            $table->string('next_pcs')->nullable(); // Permanent Change of Station
            $table->string('command');

            // Financial Information
            $table->decimal('base_pay', 8, 2);
            $table->decimal('bah', 8, 2); // Basic Allowance for Housing
            $table->decimal('tsp_savings', 10, 2); // Thrift Savings Plan
            $table->integer('retirement_points');
            $table->decimal('leave_balance', 5, 2);

            // Contact Information
            $table->string('emergency_contact_name');
            $table->string('emergency_contact_phone');
            $table->string('emergency_contact_relationship');
            $table->string('home_address');
            $table->string('city');
            $table->string('state');
            $table->string('zip_code');

            // Medical Information
            $table->enum('medical_status', ['Fit for Duty', 'Limited Duty', 'Non-Deployable', 'Medical Hold']);
            $table->date('last_physical');
            $table->text('allergies')->nullable();
            $table->enum('immunization_status', ['Up to Date', 'Overdue', 'Incomplete']);
            $table->string('dental_class');

            // Profile
            $table->text('service_brief')->nullable();
            $table->string('profile_photo')->nullable();

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('military_personnel');
    }
}
