<?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
    {
        if (Schema::hasTable('compensation_plans')) {
            return;
        }

        Schema::create('compensation_plans', function (Blueprint $table): void {
            $table->id();
            $table->decimal('binary_percentage', 8, 4)->default(0);
            $table->decimal('pair_income', 14, 2)->default(0);
            $table->decimal('daily_cap', 14, 2)->default(0);
            $table->decimal('weekly_cap', 14, 2)->default(0);
            $table->boolean('is_active')->default(true)->index();
            $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('compensation_plans');
    }
};

