test(storage): integration test for migrate-tier (FED-M1-08) + camelCase column fix #477

Merged
jason.woltje merged 1 commits from feat/federation-m1-migrate-test into main 2026-04-20 01:40:03 +00:00

1 Commits

Author SHA1 Message Date
Jarvis
efdbb13ab4 test(storage): integration test for migrate-tier PGlite → federated PG (FED-M1-08)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
Seeds a temp PGlite with representative cross-table data (users, teams,
team_members, conversations, messages), runs mosaic storage migrate-tier
against a live federated PG+pgvector profile, asserts exact row counts and
spot-checks key columns. Gated by FEDERATED_INTEGRATION=1.

Caught and fixed P0 bug in migrate-tier:

  PostgresMigrationTarget passed Drizzle-selected camelCase keys
  (emailVerified, userId, ...) verbatim as SQL identifiers, failing on
  Postgres which expects snake_case. The 32 unit tests missed this because
  both source and target were mocked. normaliseSourceRow now applies
  toSnakeCase conversion that is idempotent on already-snake_case keys.

Test infrastructure:

- packages/storage/src/test-utils/pglite-with-vector.ts: PGlite +
  @electric-sql/pglite/vector (JS-native pgvector) and migration runner.
  Co-located with storage tests rather than exposed on @mosaicstack/db
  public surface (would have polluted prod consumers with WASM bundle).
- packages/storage now declared "type": "module" (codebase convention,
  required for import.meta.url in test-utils).

afterAll cleanup deletes prefix-namespaced rows even on test panic.

Refs #460
2026-04-19 20:39:11 -05:00