4 Commits

Author SHA1 Message Date
d0d0b11dc2
feat(sqlmigrate): match applied migrations by name or ID
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.
2026-04-06 08:58:05 -06:00
657b899f1a
fix(shmigrate): restore missing-file comment, remove || true from sync
- Add # ERROR: MISSING FILE comment in generated script when a
  migration file doesn't exist (feature-branch friendly: script
  still includes the command, user decides what to do)
- Remove || true from sync lines — if the log sync query fails,
  something is seriously wrong and the script should fail
2026-04-06 00:40:12 -06:00
3461dcbc7d
fix(sqlmigrate): Down n=0 means rollback all, add tests and docs
- Change Down(n<=0) to mean "rollback all" (matching Up semantics).
  CLIs now explicitly pass 1 when no count is given.
- Add 22 tests for Collect, NamesOnly, Up, Down, and GetStatus
  using mock Migrator and fstest.MapFS.
- Fix shmigrate.Applied to stream from file instead of ReadFile
  double-wrap; add optional FS field for embed.FS support.
- Update package doc to list all 5 backends.
- Add minimal README linking to pkg.go.dev.
2026-04-06 00:40:12 -06:00
a86d901d64
feat(database/sqlmigrate): add migration library with multi-backend support
Extract a database-agnostic migration interface (Migrator) with Collect,
Up, Down, and GetStatus orchestration. Each backend is its own Go module
to avoid dependency bloat:

- sqlmigrate: core interface, types, sentinel errors, file collection
- pgmigrate: PostgreSQL via pgx/v5
- mymigrate: MySQL/MariaDB via go-sql-driver/mysql
- litemigrate: SQLite via database/sql (caller imports driver)
- msmigrate: SQL Server via go-mssqldb
- shmigrate: shell script generation (file-path commands, not heredocs)

Integrates shmigrate into the existing cmd/sql-migrate CLI, replacing
its bespoke up/down/status logic with sqlmigrate orchestration.
2026-04-06 00:40:11 -06:00