Sovite's database, through Ecto.
The adapter comes from the [database] config section: SQLite (the
default, a single file), PostgreSQL, or MySQL. Each adapter has its own
repo module, since Ecto fixes the adapter at compile time; this module
picks the one the config asks for.
The database is migrated at startup, so a new Sovite version updates
the schema by itself. Migrations are compiled modules, listed in
migrations/0, not .exs files, so they work in releases.
Functions take a repo reference, {module, name}, so several databases
can be open in one VM (tests use one per test).
Summary
Functions
The driver an adapter needs, for error messages.
Runs the pending migrations.
The migrations, in order, as {version, module}.
Returns the repo module for adapter, or nil if its driver is missing.
Returns the reference for the repo started from config (the
[database] section) under name. name defaults to the repo module.
Runs fun with the repo module, inside the process that calls it,
using the repo named in ref.
Starts the repo for config and migrates the database. With name: nil the repo is unnamed: use the returned pid in the reference.
Types
@type adapter() :: :sqlite | :postgres | :mysql
@type t() :: {module(), GenServer.server()}
A running repo: the repo module and its process name or pid.
Functions
The driver an adapter needs, for error messages.
Runs the pending migrations.
@spec migrations() :: [{pos_integer(), module()}]
The migrations, in order, as {version, module}.
Returns the repo module for adapter, or nil if its driver is missing.
Returns the reference for the repo started from config (the
[database] section) under name. name defaults to the repo module.
Runs fun with the repo module, inside the process that calls it,
using the repo named in ref.
Starts the repo for config and migrates the database. With name: nil the repo is unnamed: use the returned pid in the reference.