Fix SQL syntax error in pg_cron.schedule() calls
Replace dollar-quoted strings with simple single-quoted strings in cron.schedule() function calls. The cron.schedule() function expects text literals, not dollar-quoted blocks. Use quote_literal() for the interval value in the cleanup query to properly escape the string.
This commit is contained in:
parent
d484f62cbd
commit
20720ba541
|
|
@ -490,22 +490,21 @@ BEGIN
|
||||||
PERFORM cron.schedule(
|
PERFORM cron.schedule(
|
||||||
'notification_enqueue_every_min',
|
'notification_enqueue_every_min',
|
||||||
'*/1 * * * *',
|
'*/1 * * * *',
|
||||||
$$SELECT public.enqueue_all_notifications();$$
|
'SELECT public.enqueue_all_notifications();'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Job 2: Process notification queue via pg_net every minute
|
-- Job 2: Process notification queue via pg_net every minute
|
||||||
PERFORM cron.schedule(
|
PERFORM cron.schedule(
|
||||||
'notification_process_every_min',
|
'notification_process_every_min',
|
||||||
'*/1 * * * *',
|
'*/1 * * * *',
|
||||||
$$SELECT public.process_notification_queue();$$
|
'SELECT public.process_notification_queue();'
|
||||||
);
|
);
|
||||||
|
|
||||||
-- Job 3: Daily cleanup of old processed notifications
|
-- Job 3: Daily cleanup of old processed notifications
|
||||||
PERFORM cron.schedule(
|
PERFORM cron.schedule(
|
||||||
'cleanup_old_notifications',
|
'cleanup_old_notifications',
|
||||||
'0 3 * * *',
|
'0 3 * * *',
|
||||||
$$DELETE FROM scheduled_notifications WHERE processed = true AND processed_at < now() - interval '7 days';
|
'DELETE FROM scheduled_notifications WHERE processed = true AND processed_at < now() - interval ' || quote_literal('7 days') || '; DELETE FROM notification_pushes WHERE pushed_at < now() - interval ' || quote_literal('7 days') || ';'
|
||||||
DELETE FROM notification_pushes WHERE pushed_at < now() - interval '7 days';$$
|
|
||||||
);
|
);
|
||||||
|
|
||||||
EXCEPTION WHEN others THEN
|
EXCEPTION WHEN others THEN
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user