<?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
    {
        foreach (['care_appointments', 'care_prescriptions', 'care_investigation_requests', 'care_bills'] as $table) {
            Schema::table($table, function (Blueprint $blueprint) {
                $blueprint->string('queue_ticket_uuid', 36)->nullable()->after('uuid');
                $blueprint->string('queue_ticket_number', 32)->nullable()->after('queue_ticket_uuid');
                $blueprint->string('queue_ticket_status', 32)->nullable()->after('queue_ticket_number');
                $blueprint->index('queue_ticket_uuid');
            });
        }
    }

    public function down(): void
    {
        foreach (['care_appointments', 'care_prescriptions', 'care_investigation_requests', 'care_bills'] as $table) {
            Schema::table($table, function (Blueprint $blueprint) {
                $blueprint->dropIndex(['queue_ticket_uuid']);
                $blueprint->dropColumn(['queue_ticket_uuid', 'queue_ticket_number', 'queue_ticket_status']);
            });
        }
    }
};
