<?php

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

class AddVatEntryRelationAndPaidColumns extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // Tambah kolom di cashtransactions
        Schema::table('cashtransactions', function (Blueprint $table) {
            $table->unsignedBigInteger('vat_entry_id')
                ->nullable()
                ->after('stocktransaction_id');
        });

        // Tambah kolom di vat_entries
        Schema::table('vat_entries', function (Blueprint $table) {
            $table->decimal('paid', 15, 2)
                ->nullable()
                ->after('total_underpaid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('cashtransactions', function (Blueprint $table) {
            $table->dropColumn('vat_entry_id');
        });

        Schema::table('vat_entries', function (Blueprint $table) {
            $table->dropColumn('paid');
        });
    }
}
