Quick start
1. Import the package
Section titled “1. Import the package”In your schema-flow config, add @smplcty/schema-std to imports. The
parameter defaults make the params block optional:
# schema-flow configimports: - 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.
2. Add mixins to a table
Section titled “2. Add mixins to a table”Compose the building blocks a table needs:
# any tablemixins: [audit, audit_log, soft_delete]auditadds the four stamp columns and their triggers.audit_logrecords field-level history to theaudit_logtable.soft_deleteaddsdeleted_at.
Want creation/update times without change-attribution? Use
timestamps instead of audit —
it carries no identity-table dependency.
3. Set the actor per request
Section titled “3. Set the actor per request”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.
What you get
Section titled “What you get”| Operation | Effect |
|---|---|
INSERT | stamps created_* / updated_*; one __row__: created history marker |
UPDATE | refreshes updated_*; one history row per changed column |
no-op UPDATE | cancelled — 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 |
DELETE | one __row__: hard-deleted history marker |