<?php

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

class CreateSaleItemsTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('sale_items', function(Blueprint $table)
		{
			$table->integer('sale_id')->unsigned();
			$table->unsignedBigInteger('stock_id');
			$table->integer('quantity')->unsigned();
			$table->float('price_sold_exc')->default(0);
			$table->float('discount')->unsigned()->default(0);
			$table->boolean('refunded')->default(0);
			$table->timestamps();

			// Composite Primary KEY
			$table->primary(array('sale_id', 'stock_id'));
		});
	}

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

}
