<?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::create('employee_service_commissions', function (Blueprint $table) {
            $table->id();
            $table->foreignId('employee_id')->constrained('employees')->cascadeOnDelete();
            $table->string('service_key');
            $table->unsignedInteger('sales_percentage')->default(0);
            $table->unsignedInteger('work_percentage')->nullable();
            $table->string('work_trigger_type')->default('none');
            $table->timestamps();

            $table->unique(['employee_id', 'service_key']);
        });
    }

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