glimr/db/gen/migrate
Migration Generator
Compares current schema definitions against a stored snapshot to detect changes and automatically generate migration SQL.
The workflow is:
- Load the previous schema snapshot from JSON
- Scan current schema files in src/data/{conn_name}/models/
- Compute the diff (new tables, dropped tables, column changes)
- Generate driver-specific SQL (PostgreSQL or SQLite)
- Write migration file to src/data/{conn_name}/_migrations/
- Update the snapshot for next run
Supports column renames via the rename_from modifier, which
is automatically cleaned up after migration generation.
Run with: gleam run -m glimr/db/gen/migrate
Values
pub fn run(
name: String,
driver_type: String,
model_filter: option.Option(List(String)),
) -> Nil
Run migration generation for a named connection. Uses the folder structure:
- src/data/{name}/models/
- src/data/{name}/_migrations/
- src/data/{name}/._schema_snapshot.json