<?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('student_profiles', function (Blueprint $table) {
            $table->unsignedBigInteger('billing_account_id')->nullable()->after('user_id');

            $table->foreign('billing_account_id')
                ->references('id')->on('billing_accounts')
                ->nullOnDelete();
        });
    }

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

