<?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::create('appointments', function (Blueprint $table) {
            $table->id();
            
            // Si se borra cliente, se borran sus turnos
            $table->foreignId('client_id')->constrained()->onDelete('cascade');
            
            $table->dateTime('scheduled_at'); // Fecha y hora del turno
            $table->string('bike_model');
            $table->text('problem_description'); // Ej: "Hace ruido la caja"
            
            $table->enum('status', ['pending', 'confirmed', 'in_progress', 'ready', 'delivered'])
                ->default('pending');
                
            $table->text('notes')->nullable(); // Notas internas del mecánico
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('appointments');
    }
};
