<?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();
            $table->foreignId('category_id')->constrained('appointment_categories')->onDelete('cascade');
            $table->string('code', 15)->nullable();
            $table->string('title');
            $table->text('description')->nullable();
            $table->date('date');              // Appointment date
            $table->time('time', 5);        // Appointment time (e.g., "14:30")
            $table->string('urgency_degree', 100); // Urgency degree from 1 to 5
            $table->boolean('is_valid')->default(0);
            $table->datetime('validation_date')->nullable();
            $table->timestamps();              // created_at and updated_at
            $table->softDeletes();             // For soft deletion
        });
    }

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