<?php

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

class CreatePropertyExecutiveTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('property_executive', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('property_id');
            $table->unsignedInteger('executive_type_id');
            $table->string('name_surname',200)->nullable();
            $table->string('email',100)->nullable();
            $table->string('phone_code',10)->nullable();
            $table->string('phone',50)->nullable();
            $table->string('mobile_code',10)->nullable();
            $table->string('mobile',50)->nullable();
            $table->string('fax_code',10)->nullable();
            $table->string('fax',50)->nullable();
            $table->tinyInteger('status')->default(1);
            $table->unsignedInteger('created_by');
            $table->unsignedInteger('updated_by');
            $table->integer('created_at');
            $table->integer('updated_at');
        });

        Schema::table('property_executive',function (Blueprint $table) {
            $table->foreign('property_id')->references('id')->on('property');
            $table->foreign('executive_type_id')->references('id')->on('property_executive_type');
            $table->foreign('created_by')->references('id')->on('user');
            $table->foreign('updated_by')->references('id')->on('user');
            $table->unique(['property_id', 'executive_type_id']);
        });
    }

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