<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('members', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->nullable()->index();
            $table->string('member_id')->nullable()->unique();
            $table->string('payor_id')->nullable();
            $table->string('name_prefix')->nullable();
            $table->string('name');
            $table->string('name_suffix')->nullable();
            // $table->string('nik');
            $table->date('birth_date')->nullable();
            $table->string('gender')->nullable();
            $table->string('language')->nullable();
            $table->string('race')->nullable();
            $table->string('marital_status')->nullable();
            $table->string('record_type', 1)->nullable();
            $table->string('principal_id')->nullable()->index();
            $table->string('relation_with_principal')->nullable();
            $table->string('bpjs_class')->nullable();

            $table->string('nric')->nullable();
            $table->string('email')->nullable();
            $table->string('bank_info')->nullable();
            $table->string('agent_code')->nullable();
            $table->text('address1')->nullable();
            $table->text('address2')->nullable();
            $table->text('address3')->nullable();
            $table->text('address4')->nullable();
            $table->string('city')->nullable();
            $table->string('state')->nullable();
            $table->string('postal_code')->nullable();
            $table->string('passport_no')->nullable();
            $table->string('passport_country')->nullable();
            $table->string('identification_code')->nullable();
            $table->string('pre_existing')->nullable();
            $table->string('bpjs_id')->nullable();
            $table->string('endorsement_date')->nullable();
            $table->string('remarks')->nullable();
            $table->string('policy_in_force')->nullable();
            $table->string('start_no_claim')->nullable();
            $table->string('end_no_claim')->nullable();

            $table->boolean('active')->default(true);

            $table->timestamps();
            $table->softDeletes();
            
            $table->foreignId('created_by')->nullable();
            $table->foreignId('updated_by')->nullable();
            $table->foreignId('deleted_by')->nullable();
        });
    }

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