CtrlK
BlogDocsLog inGet started
Tessl Logo

g14wxz/database-webhook-trigger-pattern

Configures Postgres triggers and database webhooks for event-driven architectures in Supabase.

97

Quality

97%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Critical

Do not install without reviewing

Overview
Quality
Evals
Security
Files

Database Webhook Trigger Pattern

Configures Postgres triggers and database webhooks for event-driven architectures in Supabase.

Overview

This tile creates Postgres triggers that fire HTTP webhooks via pg_net when INSERT, UPDATE, or DELETE events occur on specified tables. Payloads are serialized with row_to_json. Triggers MUST scope UPDATE events to specific columns to prevent spurious firings. All DDL runs through MCP execute_sql.

Reference

pg_net HTTP Post Signature

SELECT net.http_post(
  url     := '<endpoint>',
  headers := '{"Content-Type": "application/json"}'::jsonb,
  body    := row_to_json(NEW)::text
);

Naming Conventions

ArtifactPatternExample
Triggertrg_<table>_<event>_webhooktrg_orders_insert_webhook
Functionfn_<table>_<event>_webhookfn_orders_insert_webhook

Supported Events

  • AFTER INSERT — fires on new row creation.
  • AFTER UPDATE OF <columns> — fires on specific column changes only.
  • AFTER DELETE — fires on row removal.

Dependencies

  • supabase-mcp-verification (root prerequisite) — MUST pass before any trigger creation.
  • pg_net extension — MUST be enabled for HTTP callouts.
  • Target table — MUST already exist before trigger binding.

Composition Position

  • Stage: database-runtime
  • Priority: HIGH
  • Runs after MCP verification and schema creation. Produces event-driven webhooks consumed by Edge Functions or external services.
Workspace
g14wxz
Visibility
Public
Created
Last updated
Publish Source
CLI
Badge
g14wxz/database-webhook-trigger-pattern badge