chore(postgres)!: upgrade to PostgreSQL 18 with dump/restore migration#472
Merged
Conversation
chore(postgres): upgrade to PostgreSQL 18 with dump/restore migration Bump postgres 16 → 18 in both compose files. The postgres:18 image stores its cluster in a version-specific subdir, so the volume now mounts at /var/lib/postgresql instead of /var/lib/postgresql/data. Add scripts/migrate-postgres.sh: dumps the old cluster with a temp container, recreates the volume, and restores into 18 — official images only, layout-aware, idempotent. Document in POSTGRES.md and the README update steps.
Contributor
There was a problem hiding this comment.
Pull request overview
Upgrades the bundled Docker Compose PostgreSQL service from v16 to v18 and adds guidance + a one-time dump/restore migration path so existing deployments can move their data volume across the major-version break.
Changes:
- Bump
postgresimage frompostgres:16topostgres:18in both compose files and update the volume mount path to match the new image layout. - Add
scripts/migrate-postgres.shto dump the existing cluster, recreate the volume, and restore into the new major version. - Document the required one-time migration workflow in
POSTGRES.mdand add upgrade notes/version references inREADME.mdandCONTRIBUTING.md.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/migrate-postgres.sh |
Adds an automated dump/restore workflow intended to migrate an existing named Docker volume across Postgres major versions. |
docker-compose.yml |
Updates Postgres image to 18 and remounts the pgdata volume at /var/lib/postgresql. |
docker-compose-dev.yml |
Mirrors the production compose Postgres 18 + volume mount change for dev. |
POSTGRES.md |
Adds a dedicated “Upgrading PostgreSQL major versions” section describing the migration procedure and safety notes. |
README.md |
Updates the documented Postgres version and adds an explicit note about running the migration on major bumps. |
CONTRIBUTING.md |
Updates contributor docs to reference PostgreSQL 18. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades the PostgreSQL service from 16 to 18 in both compose files, and adds a
one-time migration script so existing deployments can move their data without loss.
This implements the
postgresportion of #404 — which Renovate bundled with anemsdk bump and which has sat on hold pending a migration strategy. #404 can be
re-scoped to just the emsdk update or closed.
Deployments using the bundled
postgrescompose service must run a one-timemigration. PostgreSQL 18's on-disk format and the
postgres:18image's datadirectory layout are both incompatible with 16, so the normal update flow
(
docker compose pull && up -d) will leave Postgres unable to start untilthe data is migrated:
postgres:18refuses to start with a clear error andleaves the 16 data untouched — but the stack is down until the migration
runs. Fresh installs and external (non-compose) Postgres are unaffected.
Notes
Two incompatibilities have to be handled:
cannot start against a 16 data directory.
postgres:18image moved its data directory. 18+ images store thecluster in a version-specific subdirectory and expect the volume mounted at
/var/lib/postgresql, not/var/lib/postgresql/data(Change
PGDATAin 18+ to/var/lib/postgresql/MAJOR/dockerdocker-library/postgres#1259). Both compose files are updated accordingly.What's included
postgres:16→postgres:18indocker-compose.ymlanddocker-compose-dev.yml, with the volume remounted at/var/lib/postgresql.scripts/migrate-postgres.sh— dumps the existing cluster with a temporaryold-version container, recreates the volume, and restores into 18. It reads the old
version from the volume and the target from the compose file, so it is not
pinned to 16→18; it is layout-aware, idempotent, no-ops on fresh installs, and
sets
MSYS_NO_PATHCONVso it also runs under Git Bash on Windows.POSTGRES.md, anote in the README update steps, and version bumps in
README.md/CONTRIBUTING.md.Upgrading an existing deployment