<?php

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

class CreateInvoicesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('invoices', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id')->unsigned()->index();
            $table->integer('company_id')->unsigned()->index();
            $table->decimal('currency', 13, 3);
            $table->decimal('total', 13, 3);
            $table->decimal('tax', 13, 3)->default(0);
            $table->date('due_date')->nullable();
            $table->decimal('total_paid', 13, 3);
            $table->boolean('status')->default(0);
            $table->timestamps();

            $table->foreign('order_id')->references('id')->on('orders');
        });
    }

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