<?php

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

class CreatePropertyRoomFactMappingTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('property_room_fact_mapping', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('property_id')->unsigned();
            $table->bigInteger('room_id')->unsigned();
            $table->integer('fact_id')->unsigned();
            $table->unsignedInteger('created_by');
            $table->unsignedInteger('updated_by');
            $table->integer('created_at');
            $table->integer('updated_at');


            $table->foreign('property_id')->references('id')->on('property');
            $table->foreign('room_id')->references('id')->on('property_room');
            $table->foreign('fact_id')->references('id')->on('property_fact');
            $table->unique(['property_id', 'fact_id','room_id'],'pfr_unique');
        });
    }

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