AshSqlite.Repo behaviour (ash_sqlite v0.2.6)

View Source

Resources that use AshSqlite.DataLayer use a Repo to access the database.

This repo is a thin wrapper around an Ecto.Repo.

You can use Ecto.Repo's init/2 to configure your repo like normal, but instead of returning {:ok, config}, use super(config) to pass the configuration to the AshSqlite.Repo implementation.

Additional Repo Configuration

Because an AshPostgres.Repo is also an Ecto.Repo, it has all of the same callbacks.

In the Ecto.Repo.init/2 callback, you can configure the following additional items:

  • :tenant_migrations_path - The path where your tenant migrations are stored (only relevant for a multitenant implementation)
  • :snapshots_path - The path where the resource snapshots for the migration generator are stored.

Summary

Callbacks

Use this to inform the data layer about what extensions are installed

The path where your migrations are stored

Use this to inform the data layer about the oldest potential sqlite version it will be run on.

Allows overriding a given migration type for all fields, for example if you wanted to always use :timestamptz for :utc_datetime fields

Callbacks

installed_extensions()

@callback installed_extensions() :: [String.t()]

Use this to inform the data layer about what extensions are installed

migrations_path()

@callback migrations_path() :: String.t() | nil

The path where your migrations are stored

min_pg_version()

@callback min_pg_version() :: integer()

Use this to inform the data layer about the oldest potential sqlite version it will be run on.

Must be an integer greater than or equal to 13.

override_migration_type(atom)

@callback override_migration_type(atom()) :: atom()

Allows overriding a given migration type for all fields, for example if you wanted to always use :timestamptz for :utc_datetime fields