<?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('employee_commissions', function (Blueprint $table) {
            $table->string('source_type')->nullable()->after('status');
            $table->unsignedBigInteger('source_id')->nullable()->after('source_type');
            $table->index(['source_type', 'source_id', 'commission_type']);
        });
    }

    public function down(): void
    {
        Schema::table('employee_commissions', function (Blueprint $table) {
            $table->dropIndex(['source_type', 'source_id', 'commission_type']);
            $table->dropColumn(['source_type', 'source_id']);
        });
    }
};
