<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('membership_application_applicants', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('membership_application_id')->constrained('membership_applications')->onDelete('cascade');
            $table->string('name');
            $table->string('email');
            $table->string('ic_number');
            $table->string('birth_date');
            $table->string('birth_place');
            $table->string('marriage_status')->comment('Belum Berkahwin, Berkahwin, Bercerai, Balu, Duda');

            // contact information
            $table->text('address');
            $table->string('phone_number');
            $table->string('office_number')->nullable();
            $table->string('postcode');

            // Employment
            $table->string('employer_name');
            $table->text('employer_address');
            $table->string('current_position');
            $table->date('start_work_date');

            // contribution
            $table->decimal('stock_monthly_contribution', 10, 2);
            $table->decimal('fee_monthly_contribution', 10, 2);

            $table->timestamps();
        });

        DB::statement('
            ALTER TABLE membership_application_applicants
            ADD COLUMN gender user_gender_enum NULL
        ');
    }

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