<?php

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

class CreateJuryVotesTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('jury_votes', function (Blueprint $table) {
			$table->increments('id');
			$table->integer('voter_id')->unsigned();
			$table->integer('band_id')->unsigned();
			$table->integer('rating')->unsigned();
			$table->timestamps();

			$table->foreign('voter_id')->references('id')->on('users')->onDelete('cascade');
			$table->foreign('band_id')->references('id')->on('bands')->onDelete('cascade');
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('jury_votes', function (Blueprint $table) {
			$table->dropForeign('jury_votes_voter_id_foreign');
			$table->dropForeign('jury_votes_band_id_foreign');
		});
	}

}