Threadline.StorageSchema (Threadline v0.10.0)

Copy Markdown View Source

Resolves and validates the PostgreSQL schema that stores Threadline-owned data.

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

Functions

Returns a Threadline-owned function qualified with the configured storage schema.

Returns the configured storage schema, defaulting to the host's public schema.

Returns a stable suffix for trigger/function names derived from a host table.

Parses a host table identifier.

Returns a quoted host table identifier.

Returns a schema-qualified SQL identifier.

Returns a safely double-quoted PostgreSQL identifier.

Returns repo options that target Threadline-owned storage.

Returns a Threadline-owned table qualified with the configured storage schema.

Returns whether the name is one of Threadline's storage tables.

Validates a PostgreSQL identifier used as a schema, table, or function name.

Functions

function(name, opts \\ [])

Returns a Threadline-owned function qualified with the configured storage schema.

get(opts \\ [])

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.

host_table_suffix(value)

Returns a stable suffix for trigger/function names derived from a host table.

parse_table_identifier(value)

Parses a host table identifier.

Plain names resolve to public. Qualified names must be schema.table.

qualified_host_table(value)

Returns a quoted host table identifier.

qualify(schema, name)

Returns a schema-qualified SQL identifier.

quote_ident(identifier)

Returns a safely double-quoted PostgreSQL identifier.

repo_opts(opts \\ [])

Returns repo options that target Threadline-owned storage.

table(name, opts \\ [])

Returns a Threadline-owned table qualified with the configured storage schema.

threadline_table?(value)

Returns whether the name is one of Threadline's storage tables.

validate!(value)

Validates a PostgreSQL identifier used as a schema, table, or function name.