I love PostgreSQL, but this is just utterly annoying and discouraging to use it…
I love PostgreSQL, but this is just utterly annoying and discouraging to use it…
The issue with PostgreSQL which the Debian packages handle fine but the Docker Hub's image does not is that you need both the executables for the old and the new major version of PostgreSQL when upgrading. This just works with Debian packages but not with the Docker image.
They do handle minor versions upgrade so the code handling upgrading is there but devs seems to be quite adamant against adding major version upgrade. I (well, a lot of people judging from votes and comments in https://github.com/docker-library/postgres/issues/37 and stars in https://github.com/tianon/docker-postgres-upgrade) would love that, and only between subsequent version would be more than enough…
Minor versions of PostgreSQL have constraints that major versions don't have; in that minor versions in principle don't see new features added. This allows minor versions of the same major release to run against the same data directory without modifications.
However.
Major versions add those new features, at the cost of changes to internals that show up in things like catalog layout. This causes changes in how on-disk data is interpreted, and thus this is incompatible, and unlike minor releases this requires specialized upgrade handling.
The issue causing it is how PostgreSQL has implemented the system catalog.
I wish Docker would stop calling their unofficial Postgres images “official”. :-/ (They're “official Docker”, but not “official Postgres”. The naming is deeply misleading for everyone who is not a Docker expert.)
once the latest pgautoupgrade is available, you can do it with this:
docker run --rm \
-v YOUR_DATA_VOLUME:/var/lib/postgresql/data \
-e POSTGRES_USER=USER \
-e POSTGRES_PASSWORD=PW \
-e POSTGRES_DB=DB \
-e PGAUTO_ONESHOT=yes \
pgautoupgrade/pgautoupgrade:18-bookworm
I recommend copying the volume first, in case any mistakes occur you can rollback.Edit: Oh, for reference, I'm not using docker, just an AWS EC2 Amazon Linux instance, with a mirror on an Alpine Linux server. PostgreSQL installed via package repo, very little custom configuration.