Skip to content

feat(scripts): sync the pg resolution to @malloydata/db-postgres on Malloy bumps#868

Merged
mlennie merged 3 commits into
mainfrom
monty/sync-pg-version
Jul 20, 2026
Merged

feat(scripts): sync the pg resolution to @malloydata/db-postgres on Malloy bumps#868
mlennie merged 3 commits into
mainfrom
monty/sync-pg-version

Conversation

@mlennie

@mlennie mlennie commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to the theming PR (#786), requested by @sagarswamirao: automate the pg resolution so it stays in sync with @malloydata/db-postgres on Malloy bumps instead of being a hand-maintained magic constant.

Background: pg isn't a direct dependency; it comes in transitively via @malloydata/db-postgres, which pins its own pg (an exact 8.7.3 as of 0.0.421). #786 added a root "pg": "8.16.3" resolution so the theming family bump wouldn't downgrade the driver from main's 8.16.3, plus a manual "re-verify on the next bump" note in upgrade-malloy.sh.

This adds scripts/sync-pg-version.js, mirroring the existing scripts/sync-duckdb-version.js pattern:

  • Reads the pg version @malloydata/db-postgres declares in bun.lock (not the top-level pg entry, which is our own resolution reflected back).
  • Keeps the root resolutions.pg in sync: --write rewrites it, check mode (default) exits non-zero on drift, --print emits the version.
  • Wired into upgrade-malloy.sh (runs after the DuckDB sync, then bun install), a validate-pg-sync package script, and a "Check pg version consistency" CI gate in build.yml.

Policy: floor-guarded. resolutions.pg is set to the higher of the current pin and what db-postgres declares, so it adopts a newer pg automatically on a bump but never downgrades below the current pin. This is a superset of a literal "track db-postgres" sync: it keeps pg in step when the connector moves up, and just won't drag it backward when the connector pins an older exact version (as 0.0.421 does). Today db-postgres declares 8.7.3 and the pin is 8.16.3, so this PR is a no-op on the current tree (check mode passes, --write is a no-op).

@sagarswamirao if you'd rather it plain-track db-postgres exactly (which would set pg to 8.7.3 today, a downgrade), that's a one-line change; floor-guarded just seemed like the safer default. Happy to switch.

Verified: the sync script on the current tree (no-op) and across scenarios (connector above pin adopts it, below pin keeps the pin, range specs handled); bash/YAML/JSON syntax; typecheck, lint, and the server unit suite (1069 pass).

…alloy bumps

pg is a transitive dependency via @malloydata/db-postgres, which pins its own pg
(an exact 8.7.3 as of 0.0.421). Publisher never touches the pg Client/Pool API:
every Postgres connection goes through Malloy's connector
(PooledPostgresConnection in connection.ts) and schema listing runs standard
information_schema SQL through malloyConnection.runSQL (db_utils.ts). PR #786
added a root "pg" resolution that held pg at 8.16.3, which rode in incidentally
with the theming family bump; forcing pg above the connector's pin just runs
Malloy's connector on a driver it was not built or tested against.

Add scripts/sync-pg-version.js, mirroring scripts/sync-duckdb-version.js: it
reads the pg version @malloydata/db-postgres declares in bun.lock (not the
top-level pg entry, which is our own resolution) and keeps the root resolution
equal to it. Policy is plain-track: resolutions.pg is set to exactly what the
connector declares. To move Publisher's pg, bump pg upstream in
@malloydata/db-postgres and the next Malloy bump carries Publisher along.

On the current tree this syncs resolutions.pg from 8.16.3 down to 8.7.3, so the
package.json resolution and bun.lock are updated to match.

- upgrade-malloy.sh runs sync-pg-version.js --write (then bun install) right
  after the DuckDB sync, replacing the manual "re-verify by hand" note.
- package.json adds a validate-pg-sync script.
- build.yml adds a "Check pg version consistency" CI gate so a bump that leaves
  the resolution out of step with the connector fails the build.

Follow-up to #786, requested by Sagar.

Signed-off-by: Monty Lennie <[email protected]>
@mlennie
mlennie force-pushed the monty/sync-pg-version branch from 959005a to dae32ef Compare July 7, 2026 18:43
@mlennie
mlennie enabled auto-merge (squash) July 7, 2026 20:04
@mlennie
mlennie merged commit 709eaa1 into main Jul 20, 2026
14 checks passed
@mlennie
mlennie deleted the monty/sync-pg-version branch July 20, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants