mirror of
https://github.com/therootcompany/golib.git
synced 2026-11-04 06:55:00 +00:00
Add ID field to Migration (parsed from INSERT INTO _migrations in Collect), AppliedMigration type with ID+Name, and update Migrator.Applied() to return []AppliedMigration across all 5 backends. Matching in Up/Down/GetStatus now checks both name and ID, so renamed migration files are still recognized as applied if the 8-char hex ID matches.
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 | (generates POSIX sh) |
CLI
The sql-migrate CLI uses shmigrate to generate shell scripts for managing migrations without a Go dependency at runtime.