tickets_blocked PostgreSQL table, which temporarily holds tickets during the purchase flow.
Functions overview
| Function | Action | Table |
|---|---|---|
tickets_lock | Reserve tickets for a time window | INSERT into tickets_blocked |
tickets_unlock | Release all expired holds | DELETE from tickets_blocked where locked_up <= now |
tickets_unlock_param | Release specific tickets by ID | DELETE from tickets_blocked by ticket_id |
tickets_lock
Reserves a set of tickets for a specified time window. Before inserting, the function checks that all requested tickets are available (not sold, not already blocked).
Endpoint
Request body
Array of
ticket_id strings to lock.Duration of the hold in seconds. The
locked_up expiry timestamp is calculated as now + reserved_time.Example
What it does
- Queries
ticketsto verify all requested tickets havestatus = true(available). Returns400with anodisponiblelist if any are sold. - Queries
tickets_blockedto check none of the tickets are already locked. Returns400with anodisponiblelist if any are already held. - Inserts a row for each ticket into
tickets_blockedwithticket_id,locked_up(expiry), anddate_created.
Response
Outcome description.
200 on success, 400 if any tickets are unavailable.tickets_unlock
Deletes all rows from tickets_blocked where the locked_up expiry timestamp is in the past. Run this on a schedule or before displaying ticket availability to clear stale holds.
Endpoint
Request body
No request body is required.Example
Response
This function always returns
200. It does not report how many rows were deleted.tickets_unlock_param
Deletes specific tickets from tickets_blocked by their ticket_id. Use this to explicitly release a hold when a user abandons their cart or when a payment fails.
Endpoint
Request body
Array of
ticket_id strings to unlock. Each value must match a ticket_id in the tickets_blocked table.Example
Response
This function always returns
200. If none of the specified ticket IDs exist in tickets_blocked, the delete is a no-op.