<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('commissions', function (Blueprint $table) {
            $table->foreignId('dealer_id')->nullable()->after('agent_profile_id')->constrained()->nullOnDelete();
            $table->foreignId('transaction_id')->nullable()->after('booking_id')->constrained()->cascadeOnDelete();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('commissions', function (Blueprint $table) {
            $table->dropForeign(['dealer_id']);
            $table->dropForeign(['transaction_id']);
            $table->dropColumn(['dealer_id', 'transaction_id']);
        });
    }
};
