PostgreSQL major upgrade with pgvector
If we installed pgvector, upgrading PostgreSQL major version will not success with pg_upgrade. We need to manually dump and restore all databases.
In order to do that,
-
Start the existing version service, eg 16.
-
Run
pg_dumpall -U postgres -f /path/to/all_dumps.sql -
Stop service.
-
Upgrade
postgresql postgresql-libs postgresql-old-upgrade -
Re-compile and re-install
pgvector. -
Initialize database, such as
initdb -D /var/lib/postgres/data --locale=C.UTF-8 --encoding=UTF8 -
Start the newer version service, eg 17.
-
Login as
postgres(sudo -u postgres /bin/bash), and run
psql -f /path/to/all_dumps.sql postgres
The above steps are based on https://wiki.archlinux.org/title/PostgreSQL#Upgrading_PostgreSQL with some modifications.