# `MimirAnalytics.Schema`
[🔗](https://github.com/cash-mckeeman/mimir/blob/mimir_analytics-v0.8.1/mimir_analytics/lib/mimir_analytics/schema.ex#L1)

Canonical run-record DDL. Tables are created if absent, then missing
columns are added to existing tables. `apply/1` is idempotent.

Column additions to existing tables need an entry in `@column_migrations`;
`CREATE TABLE IF NOT EXISTS` alone does not change their columns.

# `apply`

```elixir
@spec apply(reference()) :: :ok | {:error, :name_keyed_ledger}
```

Create every table, then add any columns an older database lacks.

Returns `{:error, :name_keyed_ledger}`, changing nothing, when the database
holds an `ingest_ledger` from before the ledger was keyed by content
digest. Its entries name files, not contents, so they cannot tell whether a
file that has since grown was fully read. Such a database is rebuilt, not
migrated: delete it and re-ingest the source directories (README,
"Upgrading a database").

# `tables`

```elixir
@spec tables() :: [String.t()]
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
