Schema drift detection: PGLite ↔ Postgres parity test
The bug (v0.26.1)
exchangeClientCredentials reads token_ttl from oauth_clients and the revoke endpoint writes deleted_at. Both columns were added via manual ALTER TABLE on production Postgres but never added to pglite-schema.ts. Result: all 35 unit tests (which use PGLite) broke with column "token_ttl" does not exist.
The fix was wrapping every new-column query in try/catch, which works but is fragile — the real fix is preventing the drift.
What we need
A CI test that compares schemas and fails if they diverge:
- Table parity — every table in
schema.sql + migrations exists in pglite-schema.ts
- Column parity — every column on Postgres exists on PGLite with compatible types
- Index parity — functionally-equivalent indexes exist on both
- New column rule — any migration that adds a column to Postgres MUST also add it to
pglite-schema.ts
Trigger
Run on every PR. Should catch drift BEFORE it ships.
Context
- Discovered during v0.26.1 admin dashboard work
token_ttl, deleted_at on oauth_clients were production-only
agent_name, params, error_message on mcp_request_log same pattern
- Current workaround: try/catch around every new-column query (fragile)
Schema drift detection: PGLite ↔ Postgres parity test
The bug (v0.26.1)
exchangeClientCredentialsreadstoken_ttlfromoauth_clientsand the revoke endpoint writesdeleted_at. Both columns were added via manualALTER TABLEon production Postgres but never added topglite-schema.ts. Result: all 35 unit tests (which use PGLite) broke withcolumn "token_ttl" does not exist.The fix was wrapping every new-column query in try/catch, which works but is fragile — the real fix is preventing the drift.
What we need
A CI test that compares schemas and fails if they diverge:
schema.sql+ migrations exists inpglite-schema.tspglite-schema.tsTrigger
Run on every PR. Should catch drift BEFORE it ships.
Context
token_ttl,deleted_atonoauth_clientswere production-onlyagent_name,params,error_messageonmcp_request_logsame pattern