<?php

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

class PurchaseOrdersDetailMigration extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('purchase_orders_detail', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('quantity');
            $table->decimal('unit_price',8,2);
            $table->decimal('total',8,2);

            $table->integer('purchase_order_id')->unsigned();
      			$table->foreign('purchase_order_id')->references('id')->on('purchase_orders')->onDelete('cascade');

            $table->timestamps();
        });
    }

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