<?php

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

class CreatePartsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('parts', function(Blueprint $table)
		{
			$table->increments('id');
			$table->unsignedBigInteger('related_id');
			$table->enum('related_type', array('task', 'project'))->default('task');
			$table->unsignedBigInteger('stock_id');
			$table->integer('quantity')->unsigned();
			$table->timestamps();

			$table->unique(array('related_id', 'related_type', 'stock_id'));
		});
	}

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

}
