test(storage): integration test for migrate-tier (FED-M1-08) + camelCase column fix #477
Reference in New Issue
Block a user
Delete Branch "feat/federation-m1-migrate-test"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
FED-M1-08 — End-to-end integration test that seeds a temp PGlite, runs
mosaic storage migrate-tier, and verifies row counts + spot-checks against a live federated Postgres+pgvector profile.Real bug surfaced
The integration test caught a P0 regression in M1-05 (#474) that all 32 unit tests missed because they mocked both source and target:
DrizzleMigrationSource.readTable()returns Drizzle's selected camelCase keys (emailVerified,userId,createdAt).PostgresMigrationTarget.upsertBatch()used those keys verbatim as SQL identifiers, producingcolumn "emailVerified" does not existagainst the real federated DB.Fix:
normaliseSourceRownow applies atoSnakeCaseconversion that is idempotent on already-snake_case keys (/[A-Z]/g→_<lowercase>). All 85 prior unit tests still pass; the integration test now passes against a live stack.Test design
Seeds:
users(2),teams(1),team_members(2),conversations(2),messages(5). All rows namespaced withfed-m1-08-(text PKs) orf0000xxx-UUIDs, deleted inafterAlleven on test panic. No global state mutation. Test-prefix DELETE means--allow-non-emptyis safe to use.Test-utils placement
createPgliteDbWithVectorandrunPgliteMigrationswere initially added to@mosaicstack/dbpublic exports. Code review (sonnet) flagged this as polluting production consumers with a WASM bundle dependency. Moved topackages/storage/src/test-utils/pglite-with-vector.ts— co-located with the only consumer.Independent review + verification
Verification
Test plan
Refs #460