<?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_services', function (Blueprint $table) {
            $table->id();
            $table->foreignId('company_id')->constrained()->cascadeOnDelete();
            $table->foreignId('employee_id')->constrained()->cascadeOnDelete();
            $table->foreignId('service_id')->constrained()->cascadeOnDelete();

            // Override por empleado (opcional)
            $table->decimal('custom_price', 12, 2)->nullable();
            $table->unsignedInteger('custom_duration_minutes')->nullable();

            $table->timestamps();

            $table->unique(['employee_id', 'service_id']);
            $table->index(['company_id', 'service_id']);
        });
    }

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