{ "db_name": "PostgreSQL", "query": "\n UPDATE comms_queue\n SET status = 'processing', updated_at = NOW()\n WHERE id IN (\n SELECT id FROM comms_queue\n WHERE status = 'pending'\n AND scheduled_for <= $1\n AND attempts < max_attempts\n ORDER BY scheduled_for ASC\n LIMIT $2\n FOR UPDATE SKIP LOCKED\n )\n RETURNING\n id, user_id,\n channel as \"channel: CommsChannel\",\n comms_type as \"comms_type: CommsType\",\n status as \"status: CommsStatus\",\n recipient, subject, body, metadata,\n attempts, max_attempts, last_error,\n created_at, updated_at, scheduled_for, processed_at\n ", "describe": { "columns": [ { "ordinal": 0, "name": "id", "type_info": "Uuid" }, { "ordinal": 1, "name": "user_id", "type_info": "Uuid" }, { "ordinal": 2, "name": "channel: CommsChannel", "type_info": { "Custom": { "name": "comms_channel", "kind": { "Enum": [ "email", "discord", "telegram", "signal" ] } } } }, { "ordinal": 3, "name": "comms_type: CommsType", "type_info": { "Custom": { "name": "comms_type", "kind": { "Enum": [ "welcome", "email_verification", "password_reset", "email_update", "account_deletion", "admin_email", "plc_operation", "two_factor_code", "channel_verification", "passkey_recovery", "legacy_login_alert", "migration_verification" ] } } } }, { "ordinal": 4, "name": "status: CommsStatus", "type_info": { "Custom": { "name": "comms_status", "kind": { "Enum": [ "pending", "processing", "sent", "failed" ] } } } }, { "ordinal": 5, "name": "recipient", "type_info": "Text" }, { "ordinal": 6, "name": "subject", "type_info": "Text" }, { "ordinal": 7, "name": "body", "type_info": "Text" }, { "ordinal": 8, "name": "metadata", "type_info": "Jsonb" }, { "ordinal": 9, "name": "attempts", "type_info": "Int4" }, { "ordinal": 10, "name": "max_attempts", "type_info": "Int4" }, { "ordinal": 11, "name": "last_error", "type_info": "Text" }, { "ordinal": 12, "name": "created_at", "type_info": "Timestamptz" }, { "ordinal": 13, "name": "updated_at", "type_info": "Timestamptz" }, { "ordinal": 14, "name": "scheduled_for", "type_info": "Timestamptz" }, { "ordinal": 15, "name": "processed_at", "type_info": "Timestamptz" } ], "parameters": { "Left": [ "Timestamptz", "Int8" ] }, "nullable": [ false, false, false, false, false, false, true, false, true, false, false, true, false, false, false, true ] }, "hash": "d4c68f8502bc81c27383f15dca1990c41b5e5534a3db9c137e3ef8e66fdf0a87" }