<?php

declare(strict_types=1);

use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Migrations\Migration;

class CreateBarangayResidentsTable extends Migration
{
    public function up(): void
    {
        Schema::create('barangay_residents', function (Blueprint $table) {
            $table->id();
            $table->string('hashkey')->unique()->nullable();
            $table->unsignedBigInteger('user_id')->nullable()->index();
            $table->string('firstname');
            $table->string('middlename')->nullable();
            $table->string('lastname');
            $table->string('suffix')->nullable();
            $table->date('dob')->nullable();
            $table->string('birthplace')->nullable();
            $table->enum('gender', ['MALE', 'FEMALE', 'OTHER'])->nullable();
            $table->enum('civil_status', ['SINGLE', 'MARRIED', 'WIDOWED', 'SEPARATED', 'ANNULLED'])->nullable();
            $table->string('citizenship')->nullable()->default('Filipino');
            $table->string('religion')->nullable();
            $table->string('occupation')->nullable();
            $table->decimal('monthly_income', 12, 2)->nullable();
            $table->string('blood_type')->nullable();
            $table->boolean('voter_status')->default(false);
            $table->string('registered_voter_id')->nullable();
            $table->string('voter_precinct')->nullable();
            $table->boolean('head_of_household')->default(false);
            // Address
            $table->string('purok')->nullable();
            $table->string('street')->nullable();
            $table->string('barangay')->nullable();
            $table->string('city')->nullable();
            $table->string('province')->nullable();
            $table->string('region')->nullable();
            // Government IDs
            $table->string('philhealth_id')->nullable();
            $table->string('sss_id')->nullable();
            $table->string('gsis_id')->nullable();
            $table->string('tin')->nullable();
            // Emergency contact
            $table->string('emergency_contact_name')->nullable();
            $table->string('emergency_contact_phone')->nullable();
            $table->string('emergency_contact_address')->nullable();
            $table->boolean('is_active')->default(true);
            $table->unsignedBigInteger('created_by')->nullable();
            $table->unsignedBigInteger('updated_by')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

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