Skip to content

chore(postgres)!: upgrade to PostgreSQL 18 with dump/restore migration#472

Merged
SimmerV merged 3 commits into
MeshAddicts:developfrom
SimmerV:develop
May 21, 2026
Merged

chore(postgres)!: upgrade to PostgreSQL 18 with dump/restore migration#472
SimmerV merged 3 commits into
MeshAddicts:developfrom
SimmerV:develop

Conversation

@SimmerV
Copy link
Copy Markdown
Collaborator

@SimmerV SimmerV commented May 21, 2026

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 postgres portion of #404 — which Renovate bundled with an
emsdk bump and which has sat on hold pending a migration strategy. #404 can be
re-scoped to just the emsdk update or closed.

⚠️ Breaking change — action required for existing deployments

Deployments using the bundled postgres compose service must run a one-time
migration. PostgreSQL 18's on-disk format and the postgres:18 image's data
directory layout are both incompatible with 16, so the normal update flow
(docker compose pull && up -d) will leave Postgres unable to start until
the data is migrated:

git pull
docker compose pull
bash scripts/migrate-postgres.sh   # one-time
docker compose up -d

postgres:18 refuses to start with a clear error and
leaves 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:

  1. On-disk format — as with every PostgreSQL major version, an 18 container
    cannot start against a 16 data directory.
  2. The postgres:18 image moved its data directory. 18+ images store the
    cluster in a version-specific subdirectory and expect the volume mounted at
    /var/lib/postgresql, not /var/lib/postgresql/data
    (Change PGDATA in 18+ to /var/lib/postgresql/MAJOR/docker docker-library/postgres#1259). Both compose files are updated accordingly.

What's included

  • postgres:16postgres:18 in docker-compose.yml and
    docker-compose-dev.yml, with the volume remounted at /var/lib/postgresql.
  • scripts/migrate-postgres.sh — dumps the existing cluster with a temporary
    old-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_PATHCONV so it also runs under Git Bash on Windows.
  • Docs: a new "Upgrading PostgreSQL major versions" section in POSTGRES.md, a
    note in the README update steps, and version bumps in README.md /
    CONTRIBUTING.md.

Upgrading an existing deployment

git pull
docker compose pull
bash scripts/migrate-postgres.sh
docker compose up -d

SimmerV and others added 2 commits May 20, 2026 06:52
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.
@SimmerV SimmerV self-assigned this May 21, 2026
@SimmerV SimmerV added this to meshinfo May 21, 2026
@SimmerV SimmerV added enhancement New feature or request breaking change labels May 21, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in meshinfo May 21, 2026
@SimmerV SimmerV moved this from Backlog to In review in meshinfo May 21, 2026
@daviesgeek daviesgeek requested a review from Copilot May 21, 2026 04:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 postgres image from postgres:16 to postgres:18 in both compose files and update the volume mount path to match the new image layout.
  • Add scripts/migrate-postgres.sh to dump the existing cluster, recreate the volume, and restore into the new major version.
  • Document the required one-time migration workflow in POSTGRES.md and add upgrade notes/version references in README.md and CONTRIBUTING.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.

Comment thread scripts/migrate-postgres.sh Outdated
Comment thread scripts/migrate-postgres.sh
Comment thread POSTGRES.md Outdated
@SimmerV SimmerV merged commit 6b5c840 into MeshAddicts:develop May 21, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in meshinfo May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants