WebHare community

Updating your database to postgresql 13

Specifically for the Mac users:

cd $WEBHARE_DATAROOT  # see 'wh dirs' fo the proper value if needed
mv postgresql/db postgresql/db.bak
brew install postgresql@12
initdb -D postgresql/db --auth-local=trust -E 'UTF-8' --locale='en_US.UTF-8'
pg_upgrade -b /usr/local/Cellar/postgresql@12/12.4/bin/ -d postgresql/db.bak -D postgresql/db

If all seems fine, you can delete $WHDATA/postgresql/db.bak at some point

Note: The @ in the pg_upgrade command should be escaped, postgresql@12 is currently at version 12.4_1:

pg_upgrade -b /usr/local/Cellar/postgresql\@12/12.4_1/bin/ -d postgresql/db.bak -D postgresql/db

It seems we’re at 12.5 now:

brew install postgresql@12
Warning: postgresql@12 12.5 is already installed and up-to-date

Which makes the last command:

pg_upgrade -b /usr/local/Cellar/postgresql\@12/12.5/bin/ -d postgresql/db.bak -D postgresql/db

$(brew --prefix)/opt/postgresql@${PGVERSION}/bin/ should work in general to find a PG version

https://gitlab.com/webhare/platform/-/merge_requests/721/diffs?commit_id=03eee6ed0d2a77817797f893659538893b4c5af6 will soon try to pick the ‘right’ PG version if you have it installed. Pity I can’t see a way to get rid of the hardcoded “13” there, but once brew hits PG14 it can at least be updated manually to 14.

(this is mostly intended to be compatible with Linux PGSQL databases, which are still at version 11)