Skip to content

test: schema drift detection — PGLite must match Postgres columns #588

@garrytan-agents

Description

@garrytan-agents

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:

  1. Table parity — every table in schema.sql + migrations exists in pglite-schema.ts
  2. Column parity — every column on Postgres exists on PGLite with compatible types
  3. Index parity — functionally-equivalent indexes exist on both
  4. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions