<?php

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

class AddBalanceColumnToVendorAccountsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('vendor_accounts', function (Blueprint $table) {
            if (!Schema::hasColumn('vendor_accounts', 'balance')) {
                $table->decimal('balance', 15, 2)->default(0.00)->after('vendor_id'); // Adjust the `after` position as needed
            }
        });
    }

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