Skip to content
On this page

Namespace Plugins

sqldoc uses namespace plugins to transform SQL tags into additional SQL statements. Each namespace handles a specific concern -- audit trails, row-level security, validation, documentation, and more.

Tags are written as SQL comments (-- @namespace.tag(args)) and compiled into dialect-correct SQL at build time.

Available Namespaces

@anon
PostgreSQL Anonymizer security labels
@audit
Audit namespace plugin -- generates audit triggers for Postgres, MySQL, and SQLite. Postgres: PL/pgSQL trigger function + multi-event trigger with row_to_json. MySQL: Separate per-event triggers with inline bodies using JSON_OBJECT and explicit columns. SQLite: Separate per-event triggers with inline bodies using json_object and explicit columns.
@codegen
@comment
@deprecated
@docs
@history
History namespace plugin -- generates history tables and triggers for change tracking. Creates a {table}_history table mirroring the source table's columns plus history metadata (history_id, valid_from, valid_to, history_operation). BEFORE UPDATE/DELETE triggers copy the OLD row into the history table. Postgres: PL/pgSQL function + multi-event BEFORE trigger. MySQL: Separate per-event BEFORE triggers with explicit column enumeration. SQLite: Separate per-event BEFORE triggers with explicit column enumeration.
@lint
@pg
PostGraphile smart comments for PostgreSQL
@rls
Row-Level Security policies for PostgreSQL
@softdelete
Soft-delete namespace plugin -- generates deleted_at columns, active views, and cascade triggers. Postgres: ALTER TABLE + CREATE VIEW + PL/pgSQL cascade function + trigger. MySQL: ALTER TABLE + CREATE VIEW + per-event AFTER UPDATE cascade trigger. SQLite: ALTER TABLE + CREATE VIEW + per-event AFTER UPDATE cascade trigger.
@temporal
Temporal namespace plugin -- generates SCD Type 2 temporal tables. Adds valid_from/valid_to columns to the table, creates a current-rows view, and generates triggers for versioned row management: - INSERT: set valid_from=NOW(), valid_to=NULL - UPDATE: copy OLD row with valid_to=NOW(), set NEW.valid_from=NOW() - DELETE: archive the row (insert copy with valid_to=NOW()), then allow the delete to proceed Postgres: PL/pgSQL BEFORE trigger functions. MySQL: Limited support — DDL + view + INSERT trigger only (self-referential triggers not supported).
@validate
🚀
Created a plugin?

If you've built a namespace plugin for sqldoc, we'd love to list it here. Open an issue and we can add it to this page.