<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('business_inquiries', function (Blueprint $table) {
            if (! Schema::hasColumn('business_inquiries', 'business_type')) {
                $table->string('business_type', 50)->nullable()->after('type');
            }
            if (! Schema::hasColumn('business_inquiries', 'province_id')) {
                $table->foreignId('province_id')->nullable()->constrained()->nullOnDelete()->after('business_type');
            }
        });
    }

    public function down(): void
    {
        Schema::table('business_inquiries', function (Blueprint $table) {
            $table->dropForeign(['province_id']);
            $table->dropColumn(['business_type', 'province_id']);
        });
    }
};
