Resolves storage schema names and builds validated SQL references to Threadline-owned tables.
get/1 and repo_opts/1 apply schema configuration, table/2 names a
Threadline table, validate!/1 checks an identifier, and threadline_table?/1
recognizes Threadline table names.
Threadline defaults to the host's public schema — the schema every install
that predates this module already uses. Threadline cannot detect where an
existing install put its audit tables, so the default has to be the one that
is true for installs that already exist.
A dedicated schema is an explicit opt-in, and is the recommended choice for a NEW install:
config :threadline, storage_schema: "threadline"Any other single-segment PostgreSQL identifier works too ("audit", for
example). The choice is frozen at migration-generation time: the generated
triggers and tables are written into whichever schema was configured when
mix threadline.install ran, so changing the key afterwards requires a
migration, not just a config edit.
Summary
Types
An identifier accepted for schema validation; booleans and malformed names raise.
A parsed host table identifier with validated schema and table names.
Repository options targeting the Threadline storage schema.
Selects the identifier-validation context: :storage_schema (storage schema), :host_schema (host schema), :host_table (host table), :derived (derived identifier), or :primary_key_column (primary key column).
Functions
Returns the configured storage schema, defaulting to the host's public schema.
Returns Ecto repository options that target Threadline-owned storage.
Returns a schema-qualified SQL name for one of Threadline's storage tables.
Returns whether a valid host table identifier names one of Threadline's storage tables; raises ArgumentError for malformed identifiers.
Validates a PostgreSQL identifier and returns its trimmed name; raises ArgumentError for an invalid identifier.
Types
An identifier accepted for schema validation; booleans and malformed names raise.
A parsed host table identifier with validated schema and table names.
@type repo_opts_result() :: [{:prefix, String.t()}]
Repository options targeting the Threadline storage schema.
@type role() ::
:storage_schema | :host_schema | :host_table | :derived | :primary_key_column
Selects the identifier-validation context: :storage_schema (storage schema), :host_schema (host schema), :host_table (host table), :derived (derived identifier), or :primary_key_column (primary key column).
Functions
@spec get([Threadline.storage_schema_opt()]) :: String.t()
Returns the configured storage schema, defaulting to the host's public schema.
A dedicated schema is opted into with
config :threadline, storage_schema: "threadline", or per-call via the
:storage_schema option.
Options
:storage_schema— string. Optional. Overrides the application setting.
Returns
- The validated storage schema name.
- Raises
ArgumentErrorwhen the configured name is invalid.
Other option keys are ignored.
@spec repo_opts([Threadline.storage_schema_opt()]) :: repo_opts_result()
Returns Ecto repository options that target Threadline-owned storage.
Options
:storage_schema— string. Optional. Selects the configured storage schema.
Returns
- A
:prefixoption containing the validated Threadline storage schema. - Raises
ArgumentErrorwhen the selected storage schema is invalid.
Other option keys are ignored.
@spec table(String.t(), [Threadline.storage_schema_opt()]) :: String.t()
Returns a schema-qualified SQL name for one of Threadline's storage tables.
The accepted names are audit_transactions, audit_changes,
audit_actions, threadline_export_jobs, threadline_retention_runs,
threadline_saved_views, and threadline_evidence_records.
Options
:storage_schema— string. Optional. Selects the configured storage schema.
Returns
- The quoted, schema-qualified table name.
- Raises
FunctionClauseErrorwhennameis not one of the Threadline tables. - Raises
ArgumentErrorwhen the selected storage schema is invalid.
Other option keys are ignored.
Returns whether a valid host table identifier names one of Threadline's storage tables; raises ArgumentError for malformed identifiers.
@spec validate!(identifier_input()) :: String.t()
Validates a PostgreSQL identifier and returns its trimmed name; raises ArgumentError for an invalid identifier.