StatifierPersistence.Ecto.Config (StatifierPersistence v0.1.0)

Copy Markdown View Source

The resolved configuration behind use StatifierPersistence.Ecto.

ADR-0002 decision 3 requires that the generated schemas and the migrations helper take the same options and cannot disagree. This module is the single definition site that makes that true: __using__/1 builds a Config at the host's compile time, and the migrations helper reads the same struct (via for: HostModule) or funnels literal options through the same new/1.

Options:

  • :repo - required, the host's Ecto.Repo module
  • :key - the surrogate-key scheme, :uxid (default), :uuid, :bigserial, or {module, opts} implementing StatifierPersistence.Ecto.KeyGenerator
  • :table_prefix - prefix for the generated table names, default "statifier_"
  • :tables - per-table override map with keys :charts, :positions, :runs; an override replaces the whole name, prefix included
  • :prefix - the Postgres schema (Ecto's @schema_prefix), default nil

Unknown options and unknown table keys raise ArgumentError - at the host's compile time when reached through use.

Summary

Types

t()

Resolved configuration for one host module.

Functions

Validates and resolves the options use StatifierPersistence.Ecto accepts. Raises ArgumentError on anything malformed.

The table name (source) for table under this configuration: the per-table override when one was given, otherwise the table prefix plus the table's own name.

Types

t()

@type t() :: %StatifierPersistence.Ecto.Config{
  key: {module(), keyword()},
  prefix: String.t() | nil,
  repo: module(),
  table_prefix: String.t(),
  tables: %{
    optional(StatifierPersistence.Ecto.KeyGenerator.table()) => String.t()
  }
}

Resolved configuration for one host module.

Functions

new(opts)

@spec new(keyword()) :: t()

Validates and resolves the options use StatifierPersistence.Ecto accepts. Raises ArgumentError on anything malformed.

table(config, table)

The table name (source) for table under this configuration: the per-table override when one was given, otherwise the table prefix plus the table's own name.