Runlight.Db.Ecto (runlight v0.1.0)

Copy Markdown View Source

Runlight's statements through an app's own Ecto repo, on SQLite (ecto_sqlite3), Postgres (postgrex), or MySQL 8.4 and MariaDB 11.4 and later (myxql). The repo's adapter picks the dialect.

Runlight.Db.Ecto.new(repo: MyApp.Repo)

Options:

  • :repo (required) - the app's Ecto repo.
  • :dynamic_repo - a repo started with name: nil (its pid) or under another name, put with put_dynamic_repo/1 around each statement.

Nothing uses Ecto's schemas: every statement is the SDK's, run with the repo's query/3, and Runlight's tables are made on first use (CREATE TABLE IF NOT EXISTS), so a Node, PHP, or Elixir process can make them in any order. Statements are not logged (they would fill an app's debug log with a line for every tracker hit).

On SQLite keep ecto_sqlite3's journal_mode: :wal and give the repo a busy_timeout of at least 5000, as the SDK's SQLite store sets them. An in-memory database is one per connection, so a database: ":memory:" repo needs pool_size: 1. On MySQL and MariaDB the tables use the binary collation utf8mb4_0900_bin, which MariaDB has from 11.4.

Summary

Functions

A Runlight.Db over the repo.

Functions

new(opts)

@spec new(keyword()) :: Runlight.Db.t()

A Runlight.Db over the repo.