<?php

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

class CreateContactsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('contacts', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('reference_number')->nullable();
            $table->integer('source_id')->nullable()->index();
            $table->integer('enquiry_source_id')->nullable()->index();
            $table->integer('contact_role_id')->nullable()->index();
            $table->integer('assign_to')->nullable()->index();
            $table->string('salutation', 20)->nullable()->index();
            $table->string('name', 50)->nullable()->index();
            $table->string('phone', 50)->nullable()->index();
            $table->string('alt_phone', 50)->nullable()->index();
            $table->string('brn', 100)->nullable()->index();
            $table->string('email', 50)->nullable()->index();
            $table->string('alt_email', 50)->nullable()->index();
            $table->string('address', 300)->nullable()->index();
            $table->string('postal_address', 300)->nullable()->index();
            $table->string('website', 100)->nullable()->index();
            $table->string('tln', 100)->nullable()->index();
            $table->string('orn', 100)->nullable()->index();
            $table->string('image', 100)->nullable();
            $table->string('post_code', 20)->nullable();
            $table->date('dob')->nullable();
            $table->date('last_contact')->nullable();
            $table->string('enquiry_method', 100)->nullable();
            $table->tinyInteger('type')->default(1)->comment('1 for individual, 2 for company');
            $table->tinyInteger('gender')->nullable()->comment('1 for male, 2 for female');
            $table->tinyInteger('aml_check')->default(2);
            $table->tinyInteger('is_verified')->default(2);
            $table->string('id_title', 50)->nullable()->index();
            $table->string('id_first_name', 50)->nullable()->index();
            $table->string('id_mid_name', 50)->nullable()->index();
            $table->string('id_last_name', 50)->nullable()->index();
            $table->date('id_dob', 50)->nullable()->index();
            $table->string('id_unit_no', 50)->nullable()->index();
            $table->string('id_st_no', 50)->nullable()->index();
            $table->string('id_st_name', 50)->nullable()->index();
            $table->string('id_suburb', 50)->nullable()->index();
            $table->string('id_address', 300)->nullable()->index();
            $table->integer('added_by')->nullable()->index();
            $table->integer('updated_by')->nullable()->index();
            $table->integer('deleted_by')->nullable()->index();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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