Parameters
The package is parameterized so it depends on no app’s data model. Parameters
are supplied once, at import time, via imports[].params:
| Parameter | Default | What it controls |
|---|---|---|
user_table | users | FK target for created_by / updated_by and audit_log.changed_by |
user_pk | user_id | the primary-key column of user_table the FKs point at |
actor_guc | app.actor_id | the GUC the audit triggers read the actor id from |
lenient_guc | app.audit_lenient | GUC that, when 'true', lets audit_stamp tolerate a missing actor (bootstrap seeding) instead of raising |
All four default to the convention, so the common case is param-free:
imports: - package: '@smplcty/schema-std'Overriding
Section titled “Overriding”Override any subset; the rest keep their defaults. One override repoints
created_by, updated_by, and audit_log.changed_by at the same identity
table, because the audit and
audit_log_actor mixins share
user_table / user_pk:
imports: - package: '@smplcty/schema-std' params: user_table: accounts user_pk: account_id actor_guc: app.account_idWhere each parameter lands
Section titled “Where each parameter lands”-
user_table/user_pkare interpolated into the FKreferencesof theauditmixin’screated_by/updated_bycolumns and theaudit_log_actormixin’schanged_bycolumn:references:table: '{{user_table}}'column: '{{user_pk}}'on_delete: RESTRICTon_update: CASCADE -
actor_gucis interpolated into the function bodies ofaudit_stamp,audit_diff, andaudit_backfill_by, where the actor id is read:NULLIF(current_setting('{{actor_guc}}', true), '')::bigint -
lenient_gucis interpolated intoaudit_stamp, which raises unless this GUC is'true'when the actor is missing:current_setting('{{lenient_guc}}', true) IS DISTINCT FROM 'true'
The actor type
Section titled “The actor type”created_by / updated_by / changed_by are bigint, and the GUC value is
cast to bigint. The user_pk column you point at must be an integer key.