Skip to content

Quick start

In your schema-flow config, add @smplcty/schema-std to imports. The parameter defaults make the params block optional:

# schema-flow config
imports:
- package: '@smplcty/schema-std'
# params: { user_table: users, user_pk: user_id, actor_guc: app.actor_id }

The import pulls in the mixins, functions, and the audit_log table. They are referenced from the package, not vendored into your repo — upgrade the package and every consuming app picks up the change.

Compose the building blocks a table needs:

# any table
mixins: [audit, audit_log, soft_delete]
  • audit adds the four stamp columns and their triggers.
  • audit_log records field-level history to the audit_log table.
  • soft_delete adds deleted_at.

Want creation/update times without change-attribution? Use timestamps instead of audit — it carries no identity-table dependency.

The consuming app supplies the identity table named by user_table (default users, with a user_pk primary key) and sets the actor_guc GUC per request:

SET LOCAL "app.actor_id" = '<user_id>';

With this set, audit_stamp fills created_by / updated_by, and audit_diff writes history rows attributed to that actor.

OperationEffect
INSERTstamps created_* / updated_*; one __row__: created history marker
UPDATErefreshes updated_*; one history row per changed column
no-op UPDATEcancelled — no MVCC tuple, no updated_at bump, no history
soft delete (deleted_at set)__row__: active → archived history marker
restore (deleted_at cleared)__row__: archived → restored history marker
DELETEone __row__: hard-deleted history marker