| 1 | -- name: InsertNotification :execrows |
| 2 | -- Inserts nothing, and returns 0, when the event was handled before. |
| 3 | INSERT INTO notifications (event_id, user_id, recipient, subject) |
| 4 | VALUES ($1, $2, $3, $4) |
| 5 | ON CONFLICT (event_id) DO NOTHING; |
| 6 | |
| 7 | -- name: InsertDeadLetter :exec |
| 8 | INSERT INTO dead_letters (stream, seq, subject, payload, error, deliveries) |
| 9 | VALUES ($1, $2, $3, $4, $5, $6) |
| 10 | ON CONFLICT (stream, seq) DO NOTHING; |
| 11 | |
| 12 | -- name: ListDeadLetters :many |
| 13 | SELECT * FROM dead_letters |
| 14 | WHERE replayed_at IS NULL |
| 15 | ORDER BY failed_at; |
| 16 | |
| 17 | -- name: MarkReplayed :exec |
| 18 | UPDATE dead_letters SET replayed_at = now() |
| 19 | WHERE stream = $1 AND seq = $2; |