<?php

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

class CreateStockTransactionsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('stock_transactions', function($table){
			$table->increments('id');
			$table->enum('related_type', array('task', 'sale', 'purchase_order', 'project', 'invoice', 'custom'));
			$table->integer('related_id')->unsigned()->nullable()->index();
			$table->integer('quantity')->default(0);
			$table->string('stock_id',64);
			$table->text('reason')->nullable();
			$table->integer('created_by')->nullable()->unsigned();
			$table->integer('updated_by')->nullable()->unsigned();
			$table->softDeletes();
			$table->timestamps();
		});
	}

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

}
