Cron Jobs
The Cron Jobs component copies pg_cron scheduled tasks from the source project to the target project.
What Is pg_cron?
pg_cron is a PostgreSQL extension that allows you to schedule SQL commands at regular intervals, directly in the database. Examples:
- Purging old data every day at midnight
- Refreshing a materialized view every hour
- Sending daily statistics
What Is Copied
For each cron job:
- Name of the job
- Schedule — cron expression (e.g.
0 * * * *for every hour) - Command — the SQL query executed
- Target database
Key Considerations
| Situation | Behavior |
|---|---|
| Job with the same name on the target | Recreated (the old one is replaced) |
| Job referencing a function | The function must exist on the target (clone the Functions component) |
| Job referencing a table | The table must exist on the target (clone the Schema component) |
| pg_cron extension not enabled | Cloning this component will fail |
Warning: Cron jobs run automatically once created. If a job performs critical actions (sending emails, deleting data), make sure the target environment is ready before cloning this component.
When to Use It
- Full project migration
- Staging needs the same scheduled tasks as production
When Not to Use It
- Staging where automatic jobs could have unintended side effects (sending emails, billing, etc.)
Next Steps
- Webhooks — Event notifications
- Functions and triggers — Functions referenced by cron jobs