<?php

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

class CreatePropertyRoomRatePriceTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('property_room_rate_price', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedInteger('property_id');
            $table->unsignedBigInteger('property_room_id');
            $table->unsignedBigInteger('room_rate_mapping_id');
            $table->unsignedBigInteger('offer_id')->nullable();
            $table->unsignedInteger('channel_id')->nullable();
            $table->tinyInteger('min_stay');
            $table->tinyInteger('max_stay');
            $table->tinyInteger('stop_sell');
            $table->tinyInteger('booking_on_request');
            $table->date('date');
            $table->double('amount',10,2);
            $table->string('currency',3);

            $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('property_id')->references('id')->on('property');
            $table->foreign('property_room_id')->references('id')->on('property_room');
            $table->foreign('room_rate_mapping_id')->references('id')->on('property_room_rate_mapping');
            $table->foreign('channel_id')->references('id')->on('property_channel');
            $table->foreign('currency')->references('code')->on('currency');

        });
    }

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