lode/storage
Database storage lifecycle — create and drop the database itself (Ecto’s
Ecto.Adapters.Postgres.storage_up/storage_down, behind mix ecto.create
/ ecto.drop).
CREATE DATABASE / DROP DATABASE cannot run while connected to the target
database, so call these against a Repo connected to a different
database (conventionally postgres):
let admin = repo.new(postgres.new(maintenance_conn)) let assert Ok(Nil) = storage.create(admin, database: “my_app_dev”)
Values
pub fn create(
repo r: repo.Repo,
database name: String,
) -> Result(Nil, error.LodeError)
Create a database. Errors if it already exists (Postgres has no
CREATE DATABASE IF NOT EXISTS); treat an AdapterError mentioning
“already exists” as “already up” if you want idempotence.
pub fn drop(
repo r: repo.Repo,
database name: String,
) -> Result(Nil, error.LodeError)
Drop a database (DROP DATABASE IF EXISTS) — a no-op when it doesn’t exist.