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:

  1. Load the previous schema snapshot from JSON
  2. Scan current schema files in src/data/{conn_name}/models/
  3. Compute the diff (new tables, dropped tables, column changes)
  4. Generate driver-specific SQL (PostgreSQL or SQLite)
  5. Write migration file to src/data/{conn_name}/_migrations/
  6. 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
Search Document