Skip to content

chore(db): upgrade PGlite 0.2.17 → 0.5.4#74

Merged
zmaril merged 2 commits into
mainfrom
chore/pglite-0.5.4
Jul 3, 2026
Merged

chore(db): upgrade PGlite 0.2.17 → 0.5.4#74
zmaril merged 2 commits into
mainfrom
chore/pglite-0.5.4

Conversation

@zmaril

@zmaril zmaril commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Upgrades @electric-sql/pglite 0.2.17 → 0.5.4.

Why it's not a plain version bump

The 0.2 → 0.5 jump changes the embedded Postgres version, so the on-disk format is incompatible — a 0.5.4 server literally can't open a 0.2.17 store (verified: "failed to initialize"). The store has to be migrated across the boundary.

How the live store was migrated

Using the logical backup/restore path from #59 (version-independent by design):

backup → stop supervisor → bun install (0.5.4) → mv data/pgdata aside → restore into a fresh 0.5.4 store → serve

The old store is kept at data/pgdata.pre-0.5.4 as the rollback (downgrade the dep, move it back). All 612 rows / 11 tables carried over intact.

App-compat, verified before flipping

Ran an isolated-worktree spike under 0.5.4 (live supervisor untouched on 0.2.17 throughout) exercising every pglite-dependent path:

Path 0.5.4
Boot (pglite + live + drizzle load)
Migrations
Restore 612-row backup
Drizzle read / write
live extension — sync snapshot + write→delta
PTY
Dispatch dry-run (multi-table write)

Then flipped the live store and re-verified on it: health, data intact (m166/m199 present), /backup, and a live /sync snapshot all green on 0.5.4.

Diff is just package.json + bun.lock; the migration is an operational step (done), not code.

zmaril and others added 2 commits July 3, 2026 16:59
The 0.2 → 0.5 jump changes the embedded Postgres version, so the on-disk format
is incompatible — a straight bump can't open the existing store. Migrated the live
store across the boundary with the logical backup/restore path (backup → swap store
aside → restore into a fresh 0.5.4 store); the old store is kept at
data/pgdata.pre-0.5.4 as the rollback.

App-compat verified in an isolated worktree under 0.5.4 before flipping: boot,
migrations, drizzle read/write, the `live` extension (sync snapshot + write→delta),
PTY, and a dispatch dry-run all pass. Live store now runs 0.5.4 with all data intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaP4r6ZvUYwABKLvEy2ZRp
…rwise)

PGlite 0.5.4 exits the process with code 99 when its client is left open at exit —
so every db.ts-importing test (which opens the module client on a throwaway store
and never closes it) failed the suite, even with all assertions passing. 0.2.17
exited cleanly, so this only surfaced with the bump.

Add a `bun test --preload` teardown that closes the client after each file, guarded
to a temp PM_DATA_DIR so it never touches the live store. No production-code change;
the server never exits, so leaving the client open stays inert there.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaP4r6ZvUYwABKLvEy2ZRp
@zmaril
zmaril merged commit f417ad2 into main Jul 3, 2026
3 checks passed
@zmaril
zmaril deleted the chore/pglite-0.5.4 branch July 3, 2026 23:10
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.

1 participant