<?php

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

class CreateBomFgAltItemTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('bom_fg_alt_item', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('bom_id')->nullable()->unsigned();
            $table->foreign('bom_id')->references('id')->on('bill_of_materials');
            $table->bigInteger('alt_product_id')->nullable()->unsigned();
            $table->foreign('alt_product_id')->references('id')->on('products');
            $table->integer('qty')->default(0);
            $table->string('comment')->nullable();
            $table->double('cost_allocation')->nullable();
            $table->softDeletes();
            $table->timestamps();
        });
    }

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