lode/migration/gen
Generate a migration-module skeleton (Ecto’s mix ecto.gen.migration).
There is no mix, so this is pure source generation: module_source
returns the text of a migration module and file_name its conventional
file name. Wire them into a small gleam run entrypoint that supplies a
timestamp version (e.g. from gleam/time) and writes the file with
simplifile — the same offline-codegen pattern lode/codegen uses.
// scripts/gen_migration.gleam pub fn main() { let version = current_utc_stamp() // YYYYMMDDHHMMSS as an Int let src = gen.module_source(name: “add_users”, version: version) let assert Ok(_) = simplifile.write(to: “src/” <> gen.file_name(“add_users”), contents: src) }
Values
pub fn file_name(name name: String) -> String
The migration module’s file name, <name>.gleam. Unlike Ecto’s
<timestamp>_<name> (where migrations are loaded by path), lode
migrations are modules — a Gleam module name can’t start with a digit — so
the file carries no timestamp prefix; ordering is by the version inside
migration.new(...).
pub fn module_source(
name name: String,
version version: Int,
) -> String
The source of a migration module over version, with a commented skeleton
to fill in. The generated module exposes pub fn migration().