<?php

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

class CreatePropertyRoomRateMappingTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('property_room_rate_mapping', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('room_id');
            $table->unsignedBigInteger('room_rate_id');
            $table->mediumText('description');
            $table->double('rack_rate',10,2);
            $table->tinyInteger('included_occupancy');
            $table->tinyInteger('independent_availability');
            $table->tinyInteger('default_stop_sell');
            $table->tinyInteger('booking_on_request');
            $table->tinyInteger('status')->default(1);
            $table->unsignedInteger('created_by');
            $table->unsignedInteger('updated_by');
            $table->integer('created_at');
            $table->integer('updated_at');

            $table->foreign('created_by')->references('id')->on('user');
            $table->foreign('updated_by')->references('id')->on('user');
            $table->foreign('room_id')->references('id')->on('property_room');
            $table->foreign('room_rate_id')->references('id')->on('property_room_rate');
            $table->unique(['room_id', 'room_rate_id'], 'room_room_rate_mapping');

        });
    }

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