<?php

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

class CreateVotesTable extends Migration {

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

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

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::table('votes', function($table)
		{
			$table->dropForeign('votes_band_id_foreign');
			$table->dropForeign('votes_voter_id_foreign');
		});

		Schema::drop('votes');
	}

}

