mirror of
https://github.com/therootcompany/golib.git
synced 2026-04-24 12:48:00 +00:00
Passing 0 to Up() or Down() is an easy mistake — it silently means "all" which could be destructive. Now n=0 returns ErrInvalidN. Convention: n > 0 for a specific count, n < 0 (typically -1) for all.
23 lines
1.2 KiB
Markdown
23 lines
1.2 KiB
Markdown
# sqlmigrate
|
|
|
|
Database-agnostic SQL migration library for Go.
|
|
|
|
[](https://pkg.go.dev/github.com/therootcompany/golib/database/sqlmigrate)
|
|
|
|
## Backend packages
|
|
|
|
Each backend is a separate Go module to avoid pulling unnecessary drivers:
|
|
|
|
| Package | Database | Driver |
|
|
|---------|----------|--------|
|
|
| [pgmigrate](https://pkg.go.dev/github.com/therootcompany/golib/database/sqlmigrate/pgmigrate) | PostgreSQL | pgx/v5 |
|
|
| [mymigrate](https://pkg.go.dev/github.com/therootcompany/golib/database/sqlmigrate/mymigrate) | MySQL / MariaDB | go-sql-driver/mysql |
|
|
| [litemigrate](https://pkg.go.dev/github.com/therootcompany/golib/database/sqlmigrate/litemigrate) | SQLite | database/sql (caller imports driver) |
|
|
| [msmigrate](https://pkg.go.dev/github.com/therootcompany/golib/database/sqlmigrate/msmigrate) | SQL Server | go-mssqldb |
|
|
| [shmigrate](https://pkg.go.dev/github.com/therootcompany/golib/database/sqlmigrate/shmigrate) | Shell scripts | (uses native CLI) |
|
|
|
|
## CLI
|
|
|
|
The [sql-migrate](https://pkg.go.dev/github.com/therootcompany/golib/cmd/sql-migrate/v2) CLI
|
|
uses _shmigrate_ to generate shell scripts for managing migrations without a Go dependency at runtime.
|