<?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::table('care_practitioners', function (Blueprint $table) {
            $table->string('room')->nullable()->after('specialty');
        });

        foreach (['care_appointments', 'care_prescriptions', 'care_investigation_requests', 'care_bills'] as $tableName) {
            Schema::table($tableName, function (Blueprint $blueprint) {
                $blueprint->string('queue_service_point_uuid', 36)->nullable()->after('queue_ticket_status');
                $blueprint->string('queue_destination', 255)->nullable()->after('queue_service_point_uuid');
                $blueprint->string('queue_staff_display_name', 255)->nullable()->after('queue_destination');
                $blueprint->string('queue_routing_status', 32)->nullable()->after('queue_staff_display_name');
            });
        }
    }

    public function down(): void
    {
        foreach (['care_appointments', 'care_prescriptions', 'care_investigation_requests', 'care_bills'] as $tableName) {
            Schema::table($tableName, function (Blueprint $blueprint) {
                $blueprint->dropColumn([
                    'queue_service_point_uuid',
                    'queue_destination',
                    'queue_staff_display_name',
                    'queue_routing_status',
                ]);
            });
        }

        Schema::table('care_practitioners', function (Blueprint $table) {
            $table->dropColumn('room');
        });
    }
};
