Files
tinker_tickets/migrations/007_notification_retry_queue.sql
T

21 lines
990 B
SQL
Raw Normal View History

-- Queue for Matrix webhook notifications that failed to send (#78).
--
-- NotificationHelper::fire() previously logged a failed webhook post via
-- error_log() only, with no retry and no persistent record — once a
-- notification failed, it was gone. Failed payloads are now queued here and
-- retried by cron/retry_failed_notifications.php with exponential backoff.
--
-- Safe to re-run.
CREATE TABLE IF NOT EXISTS `notification_retry_queue` (
`retry_id` int(11) NOT NULL AUTO_INCREMENT,
`payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`payload`)),
`attempts` int(11) NOT NULL DEFAULT 0,
`max_attempts` int(11) NOT NULL DEFAULT 6,
`next_attempt_at` timestamp NULL DEFAULT current_timestamp(),
`last_error` varchar(500) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
PRIMARY KEY (`retry_id`),
KEY `idx_next_attempt` (`next_attempt_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;