Generates an Ecto migration that installs Threadline audit triggers on the specified tables.
Usage
mix threadline.gen.triggers --tables users
mix threadline.gen.triggers --tables users,posts,commentsEach invocation produces one migration file containing CREATE TRIGGER
statements for all listed tables. Run mix ecto.migrate to apply.
The trigger calls threadline_capture_changes(), which must already be
installed via mix threadline.install.
With before-values capture for opted-in tables:
mix threadline.gen.triggers --tables posts --store-changed-from
mix threadline.gen.triggers --tables posts --store-changed-from --except-columns secret_token,internal_scoreThat emits per-table functions threadline_capture_changes_<table>() and wires
triggers to them. Migrations generated without --store-changed-from keep the
default global threadline_capture_changes() trigger body unless the table
has :exclude / :mask rules under config :threadline, :trigger_capture (see
README).
Redaction (config :threadline, :trigger_capture)
At task start the host app config is loaded (Mix.Task.run("app.config", [])).
Per-table entries under :tables may set :exclude, :mask, optional
:mask_placeholder, :store_changed_from, and :except_columns. Overlap
between :exclude and :mask is validated with Threadline.Capture.RedactionPolicy
before writing the migration.
Options
--tables— comma-separated list of table names (required)--store-changed-from— emit per-table capture functions that persist sparsechanged_fromJSON on UPDATE (default: off)--except-columns— comma-separated column names excluded from bothchanged_fieldsandchanged_fromwhen--store-changed-fromis set (alphanumeric and underscore only). Merged with:except_columnsfrom config.--dry-run— printtable=… exclude=… mask=…per table and skip writing a migration
Guards
The task exits non-zero if audit_transactions or audit_changes is in the
table list. Installing audit triggers on Threadline's own tables would cause
recursive loops (D-10, CAP-10).