---
title: "How to fix missing table errors in pg_cron"
description: "pg_cron stores scheduled jobs as raw SQL text, separate from Postgres' system catalogs, so dropping a table leaves jobs that fail every run with \"relation does not exist\" and fill cron.job_run_details with errors."
url: "https://swe.quest/articles/how-to-fix-missing-table-errors-in-pg-cron-3e70d0e00b3759de"
canonical: "https://neon.com/blog/how-to-fix-missing-table-errors-in-pg_cron"
source: "Neon"
published: "2025-07-14"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["postgres","scheduling","sql"]
---

# How to fix missing table errors in pg\_cron

A post on [Neon](https://swe.quest/sources/neon.md), published 2025-07-14, 8 min read, How-to. Original: [https://neon.com/blog/how-to-fix-missing-table-errors-in-pg\_cron](https://neon.com/blog/how-to-fix-missing-table-errors-in-pg_cron)

## Summary

pg\_cron stores scheduled jobs as raw SQL text, separate from Postgres' system catalogs, so dropping a table leaves jobs that fail every run with "relation does not exist" and fill cron.job\_run\_details with errors. Manual unscheduling, defensive DO blocks and cleanup jobs all leave gaps. A roughly 30-line PL/pgSQL event trigger on sql\_drop closes them: it calls pg\_event\_trigger\_dropped\_objects() and unschedules any cron.job whose command mentions the dropped table name. The post also lists operational practices, such as explicit statement\_timeout, setting search\_path, and purging run history, and says when Airflow or Inngest fit better than pg\_cron.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Scheduling](https://swe.quest/tags/scheduling.md) (Distributed systems)
- [SQL](https://swe.quest/tags/sql.md) (Languages)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- PL/pgSQL functions
- cron syntax

## Keywords

pg\_cron, PostgreSQL, event triggers, Neon, PL/pgSQL

## Related posts

- [Run Scheduled and Recurring Tasks with Cron](https://swe.quest/articles/run-scheduled-and-recurring-tasks-with-cron-ca49b6813f0599a8.md): Railway · 2025-11-26 · Medium · 10 min read · Scheduling, Deployment, PostgreSQL
  Cron runs commands on time-based schedules but keeps no job history, has no retries and does no concurrency control, so reliability depends on the job itself.
- [Postgres as a CRON Server](https://swe.quest/articles/postgres-as-a-cron-server-d7e215165e9a3fbe.md): Supabase · 2021-03-05 · Medium · 6 min read · PostgreSQL, Scheduling, SQL
  Postgres can act as a cron server by combining the pg\_cron extension for scheduling with the pgsql-http extension for outbound HTTP calls, letting a scheduled SQL statement POST to a webhook every minute.
- [Your Neon Functions can now run on a schedule](https://swe.quest/articles/your-neon-functions-can-now-run-on-a-schedule-72b4a206b2b5554b.md): Neon · 2026-09-21 · Medium · 5 min read · Serverless, PostgreSQL, Scheduling
  Neon Function Triggers let Neon invoke a deployed Node.js function on a cron schedule.
- [Postgres Event Triggers Are Now Supported in Neon](https://swe.quest/articles/postgres-event-triggers-are-now-supported-in-neon-6c294c5befac4572.md): Neon · 2025-07-03 · Medium · 3 min read · PostgreSQL, Schema migrations
  Neon now supports Postgres event triggers through the neon\_superuser role, and they behave exactly as in vanilla Postgres.
- [Post mortem on Linear incident from Jan 24th, 2024](https://swe.quest/articles/post-mortem-on-linear-incident-from-jan-24th-2024-c1bcc35cc14b559c.md): Linear · 2024-01-30 · Medium · 9 min read · Incidents & postmortems, PostgreSQL, Schema migrations, Local-first & sync
  A database migration using \`TRUNCATE TABLE ... CASCADE\` on two new, unused tables silently wiped every production table with foreign keys to them, including issue and document descriptions, comments, notifications and reactions.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
