Skip to content

Parameters

The package is parameterized so it depends on no app’s data model. Parameters are supplied once, at import time, via imports[].params:

ParameterDefaultWhat it controls
user_tableusersFK target for created_by / updated_by and audit_log.changed_by
user_pkuser_idthe primary-key column of user_table the FKs point at
actor_gucapp.actor_idthe GUC the audit triggers read the actor id from
lenient_gucapp.audit_lenientGUC 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'

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_id
  • user_table / user_pk are interpolated into the FK references of the audit mixin’s created_by / updated_by columns and the audit_log_actor mixin’s changed_by column:

    references:
    table: '{{user_table}}'
    column: '{{user_pk}}'
    on_delete: RESTRICT
    on_update: CASCADE
  • actor_guc is interpolated into the function bodies of audit_stamp, audit_diff, and audit_backfill_by, where the actor id is read:

    NULLIF(current_setting('{{actor_guc}}', true), '')::bigint
  • lenient_guc is interpolated into audit_stamp, which raises unless this GUC is 'true' when the actor is missing:

    current_setting('{{lenient_guc}}', true) IS DISTINCT FROM 'true'

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.