cron-postgres
The default cron adapter. Uses the pg_cron extension to schedule jobs and inserts payloads directly into a @pgshift/queue table when they fire.
This adapter is bundled with @pgshift/cron. You do not need to install it separately.
How it works
Section titled “How it works”When you call db.cron(name).schedule(expr, options), the adapter:
- Removes any existing
pg_cronjob with the same name. - Registers a new job via
cron.schedule(name, expr, sql). - The SQL inserts a row into the target
_pgshift_queue_*table withstatus = 'pending'.
Your @pgshift/queue worker then picks it up as a normal job.
All PgShift-managed jobs use the pgshift: prefix in pg_cron, so they are namespaced away from any other jobs you may have.
Schema used
Section titled “Schema used”The adapter writes into the existing queue table:
INSERT INTO _pgshift_queue_tasks (payload, status, run_at)VALUES ('{"type":"cleanup"}'::jsonb, 'pending', NOW())No additional tables are created by the cron adapter itself.
Requirements
Section titled “Requirements”- PostgreSQL 12 or later
pg_cronextension installed and enabled
pg_cron installation
Section titled “pg_cron installation”On managed providers:
- AWS RDS / Aurora: enable via parameter group (
shared_preload_libraries = pg_cron) and restart the instance. - Supabase:
pg_cronis pre-installed. Calldb.cron.setup()to activate it. - Self-hosted: install the extension package (
postgresql-{version}-cron) and addpg_crontoshared_preload_librariesinpostgresql.conf.
Internal tables
Section titled “Internal tables”| Table | Purpose |
|---|---|
cron.job | Native pg_cron job registry (read-only from PgShift) |
_pgshift_queue_{name} | Queue table where job payloads are inserted |