<?php

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

class CreateReservationsTable extends Migration
{

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('reservations', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('reference_number');
			
			$table->integer('user_id')->unsigned()->index();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

			$table->integer('boat_id')->unsigned()->index();
            $table->foreign('boat_id')->references('id')->on('boat')->onDelete('cascade');

			$table->string('first_name', 60);
			$table->string('last_name', 60);
			$table->string('telephone', 20);
			$table->string('email');

			$table->date('date_start');
			$table->date('date_end');

			$table->integer('schedule_id')->unsigned()->index();
            $table->foreign('schedule_id')->references('id')->on('schedule')->onDelete('cascade');
			
			$table->boolean('status_id');
			$table->text('comments')->nullable()->default(null);


		    $table->softDeletes();
            $table->timestamps();
		});
	}

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

}
