How amacneil/dbmate works
Dbmate is a standalone SQL database migration CLI. The main workflow is to create timestamped migration files, apply or roll them back through the selected database driver, and optionally save a schema dump. The README also documents database creation and removal, status, schema loading, and connection waiting. The graph includes the Go driver layer and the TypeScript npm launcher; some driver internals and command-to-method links are documented capabilities rather than fully sampled implementations.
Main entry points: main.go Go CLI · db.go Migration operations · resolveBinary.ts Binary resolver · postgres.go Postgres driver
Components 16
CLI and distribution
- Go CLI
main.go - npm launcher
typescript/packages/dbmate/src/cli.ts - Binary resolver
typescript/packages/dbmate/src/resolveBinary.ts
Migration lifecycle
- SQL migration files
- Migration operations
pkg/dbmate/db.go - Migration parsing
pkg/dbmate/migration.go
Database drivers
- Driver interface
pkg/dbmate/driver.go - Postgres driver
pkg/driver/postgres/postgres.go - MySQL driver
pkg/driver/mysql/mysql.go - SQLite driver
pkg/driver/sqlite/sqlite.go - ClickHouse driver
pkg/driver/clickhouse/clickhouse.go - BigQuery driver
pkg/driver/bigquery/bigquery.go
Schema and utilities
- Database utilities
pkg/dbutil/dbutil.go - Schema file
Other components
- CLI user
- Database server
Connections 18
- CLI user → Go CLI: runs commands
README.md - Go CLI → Migration operations: invokes operations
main.go - Go CLI → Postgres driver: imports driver
main.go - Go CLI → MySQL driver: imports driver
main.go - Go CLI → ClickHouse driver: imports driver
main.go - Go CLI → BigQuery driver: imports driver
main.go - Go CLI → SQLite driver: imports driver
- Migration operations → Driver interface: uses interface
pkg/dbmate/db.go - Migration operations → Database utilities: uses utilities
pkg/dbmate/db.go - Migration operations → SQL migration files: reads and writes
README.md - Migration operations → Schema file: dumps or loads
README.md - Postgres driver → Database server: connects to
README.md - MySQL driver → Database server: connects to
README.md - SQLite driver → Database server: connects to
README.md - ClickHouse driver → Database server: connects to
README.md - BigQuery driver → Database server: connects to
README.md - npm launcher → Binary resolver: resolves binary
typescript/packages/dbmate/src/cli.ts - Binary resolver → Go CLI: locates executable