<?php

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

class CreateReviews extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('reviews', function(Blueprint $table)
		{
			$table->bigIncrements('id');
			$table->text('body')->nullable();
			$table->integer('score')->nullable()->index();
			$table->integer('title_id')->unsigned()->index();
			$table->integer('user_id')->unsigned()->index();
			$table->timestamp('created_at')->nullable();
			$table->timestamp('updated_at')->nullable();

            $table->unique(['title_id', 'user_id']);

            $table->collation = config('database.connections.mysql.collation');
            $table->charset = config('database.connections.mysql.charset');
		});
	}

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

}
