<?php

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

class CreateRoomsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if(!Schema::hasTable('rooms')) {
            Schema::create('rooms', function (Blueprint $table) {
                $table->increments('id');
                $table->timestamps();

                $table->unsignedInteger('created_by');
                $table->unsignedInteger('last_updated_by')->nullable();

                $table->unsignedInteger('hostels_id');
                $table->unsignedInteger('room_type');
                $table->integer('room_number');
                $table->integer('rate_perbed')->default(0);
                $table->text('description')->nullable();
                $table->boolean('status')->default(1);

                $table->foreign('hostels_id')->references('id')->on('hostels');
                $table->foreign('room_type')->references('id')->on('room_types');
            });

        }
    }

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