Managing PostgreSQL versions
Usually, we are shipping three versions of PostgreSQL. We need to support running on all versions, as well as upgrading from the older versions to the newest.
Software definitions
The software definitions are in:
config/software/postgresql_old.rbconfig/software/postgresql.rbconfig/software/postgresql_new.rb
Default version
The version that should be installed by default is controlled by using the ‘link bin files’ step. The software definition with this step will be used on a new installation.
Upgrading
The gitlab-ctl pg-upgrade command is used to upgrade from postgresql_old or postgresql to postgresql_new. See our documentation for how to use it
Automatic upgrades
The gitlab-ctl pg-upgrade command is run on every upgrade. The default version used in the upgrade and revert command need to changed when wanting to change with PostgreSQL version gets automatically upgraded to during install.
Removing an older version
When it is time to remove an older version, perform the following steps:
- Run
git rm config/software/postgresql_old.rb - Run
git mv config/software/postgresql{,_old}.rb - Edit
config/software/postgresql_old.rband change name frompostgresqltopostgresql_old - Run
git mv config/software/postgresql{_new,}.rb - Edit
config/software/postgresql.rband change name frompostgresql_newtopostgresql
Adding a new version
We currently support shipping three versions:
- Run
git cp config/software/postgresql{,_new}.rb -
Edit
config/software/postgresql_new.rb. Update:-
nametopostgresql_new -
default_versionto the new version -
versionto have the new version, and thesha256 -
major_versionif necessary
-
Additionally, ensure that:
- The package build includes both versions of PostgreSQL
- Running
gitlab-ctl pg-upgradeworks
The case of libpq
Some modules, including pyscopg2, depend on PostgreSQL client library, i.e. libpq. It should be always linked to the
latest bundled version. By using the latest version we rely on backward compatibility of libpq.