<?php

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

class AddGvnNoToFunctionTypesTable extends Migration
{
    public function up()
    {
        Schema::table('function_types', function (Blueprint $table) {
            $table->unsignedBigInteger('gvn_no')
                  ->nullable()
                  ->after('Act_Id');

            $table->foreign('gvn_no')
                  ->references('gvn_no')
                  ->on('gen_voucher_no')
                  ->onDelete('set null');
        });
    }

    public function down()
    {
        Schema::table('function_types', function (Blueprint $table) {
            $table->dropForeign(['gvn_no']);
            $table->dropColumn('gvn_no');
        });
    }
}
