Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 3 min read Announcement mediumAdept

Postgres Event Triggers Are Now Supported in Neon

Neon now supports Postgres event triggers through the neon_superuser role, and they behave exactly as in vanilla Postgres. Unlike row-level triggers, event triggers fire on DDL commands such as CREATE, ALTER and DROP. They can audit schema changes on ddl_command_end, automate metadata updates or alerts, and feed schema changes to sync engines like Zero via pg_event_trigger_ddl_commands(). Short examples show blocking DROP TABLE for non-admin roles and cleaning up orphaned pg_cron jobs on sql_drop using pg_event_trigger_dropped_objects().

Assumes: PostgreSQL DDLPL/pgSQL functions

Related posts

  • Postgres as Your Platform: Building Event-Driven Systems with Schema Changes

    Neon mediumAdept

    Postgres event triggers, transactional DDL and LISTEN/NOTIFY can turn schema changes into reliable events that drive downstream automation such as SDK generation, warehouse syncs and documentation updates, with no external queue. The pattern uses a ddl_command_end event trigger that writes pg_event_trigger_ddl_commands() metadata to an outbox table and calls pg_notify, all inside the DDL transaction, so events exist exactly when the schema change commits. A Python psycopg2 worker listens for notifications and claims rows from the outbox, which also supports polling fallback, replay and monitoring of backlog. Practical details cover tagging tenant schemas, using a session setting to avoid infinite loops when automation itself runs DDL, connecting directly rather than through a pooler, and keeping Neon listeners from scaling to zero.

  • PostgreSQL Event Triggers without superuser access

    Supabase hardMaster

    Supabase's supautils extension lets non-superusers create Postgres Event Triggers by intercepting `create event trigger` from a "privileged role" via ProcessUtility_hook, temporarily elevating to superuser for creation, then assigning ownership back to the privileged role. Because event triggers fire for every role with the invoking role's privileges, this alone would allow privilege escalation, such as a trigger that runs `alter role ... superuser` when a superuser executes DDL. To prevent that, the extension uses fmgr_hook to replace user event trigger functions with a no-op (`version()`) whenever a superuser or reserved role is executing. The feature is live for new Supabase projects, and upstream patches proposing more restricted user event triggers in Postgres core are under discussion.

  • When a file is uploaded, run the job on Neon

    Neon mediumAdept

    Neon added a storage_object_created function trigger that invokes a Neon Function via HTTP POST when an object is created in a Neon Object Storage bucket, optionally filtered by key prefix. The payload carries the bucket name and object key. Functions are long-running and scale to zero, and they wake Postgres compute on demand. Example pipelines include cataloging uploads in Postgres, generating image variants under a separate prefix to avoid self-triggering, AI tagging, PDF chunking and embedding for search, and moderation, which runs after the upload lands and so cannot block it. Triggers branch with the data but are disabled by default on child branches, and they can be declared in a neon.ts config file alongside buckets and functions.

  • Your Neon Functions can now run on a schedule

    Neon mediumAdept

    Neon Function Triggers let Neon invoke a deployed Node.js function on a cron schedule. Because the timer lives outside the Postgres compute, scheduled jobs keep working with scale to zero, unlike pg_cron, which only runs while the compute is up and can only execute SQL. Triggers are branch-scoped, and child branches inherit their parent's triggers in a disabled state, so branching production doesn't double-fire jobs. A worked example uses a Hono handler that verifies the X-Neon-Trigger-Invocation-Id header, reads scheduled_at from the request body, and uses ON CONFLICT DO NOTHING to stay idempotent, plus the API call that creates a 15-minute schedule.

  • Just landed in the Neon CLI

    Neon mediumAdept

    The Neon CLI is renamed from neonctl to neon (old name kept as an alias) and gains a branch-first workflow built on `neon link`, `neon checkout` and `neon env pull`, which store project/branch context in a local .neon file and rewrite only Neon-managed env vars. New commands include `neon inspect db` for read-only Postgres diagnostics (bloat, unused indexes, locks, pg_stat_statements outliers, cache hit rate), `neon diff` for git-style schema diffs, snapshots, project-scoped API keys and credential profiles for CI and agents, and a raw `neon api` fallback. `neon init` sets up MCP and agent skills in one step, and a suggested AGENTS.md snippet steers coding agents toward the branch-per-feature loop.

The quest for software engineering knowledge.

Look:
Layout: