mirror of
https://github.com/therootcompany/golib.git
synced 2026-11-04 06:55:00 +00:00
- Add ErrMissingScript sentinel for unknown applied migrations in Down (previously misused ErrMissingDown when entire script was missing) - Wrap Applied() errors with ErrQueryApplied in Up, Down, GetStatus - Check ctx.Err() between migration loop iterations in Up and Down - Tighten litemigrate error match to "no such table: _migrations" - Return error from logMigrationsSelect instead of calling os.Exit(1) - Check os.WriteFile errors in create command - Split main.go (1147 lines) into main.go, init.go, fixup.go, create.go
sqlmigrate
Database-agnostic SQL migration library for Go.
Backend packages
Each backend is a separate Go module to avoid pulling unnecessary drivers:
| Package | Database | Driver |
|---|---|---|
| pgmigrate | PostgreSQL | pgx/v5 |
| mymigrate | MySQL / MariaDB | go-sql-driver/mysql |
| litemigrate | SQLite | database/sql (caller imports driver) |
| msmigrate | SQL Server | go-mssqldb |
| shmigrate | Shell scripts | (uses native CLI) |
CLI
The sql-migrate CLI uses shmigrate to generate shell scripts for managing migrations without a Go dependency at runtime.