3 Commits

Author SHA1 Message Date
3402b60bc6
fix(sqlmigrate): defensive table-missing check at rows.Err() across backends
Apply the same lazy-error pattern fix to all backends, plus regression
tests that catch the bug.

pgmigrate is the confirmed-broken case (pgx/v5's Conn.Query is lazy and
surfaces 42P01 at rows.Err() once the prepared statement cache is primed).
The defensive check at rows.Err() is also added to mymigrate and msmigrate
in case their drivers exhibit similar behavior in some configurations.

litemigrate is refactored to probe sqlite_master with errors.Is(sql.ErrNoRows)
instead of string-matching the error message — SQLite returns the generic
SQLITE_ERROR code for "no such table" so a typed-error approach isn't
possible at the driver layer; the probe lets us use idiomatic errors.Is.

Tests:
- litemigrate: in-memory SQLite, runs on every go test (no infra)
- pgmigrate:   PG_TEST_URL env-gated; verified against real Postgres,
               TestAppliedAfterDropTable reproduces the agent's exact error
               message ("reading rows: ... 42P01") without the fix
- mymigrate:   MYSQL_TEST_DSN env-gated
- msmigrate:   MSSQL_TEST_URL env-gated; verified against real SQL Server

Each backend has four cases: missing table, populated table, empty table,
and table-dropped-after-cache-primed (the lazy-error scenario).
2026-04-10 00:15:06 -06:00
5783d4fc7a
ref(backends): update all backends and sql-migrate to sqlmigrate v1.0.2
ExecUp/ExecDown now take (ctx, Migration, sql string) instead of
(ctx, Migration) with embedded Up/Down fields. Applied returns
[]Migration instead of []AppliedMigration.

- pgmigrate, mymigrate, litemigrate, msmigrate: new interface, v1.0.2 dep
- shmigrate: v1.0.2 dep, remove temporary replace directive
- cmd/sql-migrate: v1.0.2 dep
2026-04-09 03:27:35 -06:00
9fb5b4eda6 feat(litemigrate): add SQLite backend for sqlmigrate 2026-04-09 02:37:35 -06:00