Automatically run pg_upgrade when major PostgreSQL upgrade is detected

Authored by dvratil on May 21 2019, 2:06 PM.

Description

Automatically run pg_upgrade when major PostgreSQL upgrade is detected

Summary:
This implements detection of version of the db_data cluster and the currently
installed Postgres version (on Linux for now, only), and upgrading the cluster
when Postgres major version upgrade is detected.

This should make it more comfortable for users to use Akonadi with Postgres
since they no longer have to care about Postgres upgrades. The upgrade
will fail if we fail to find executables for the previous Postgres
server version (the one from which we are upgrading), which may differ
between distributions and usually requires an additional package to be
installed.

The process involves creating a new db cluster using the new version of Postgres,
then basically dumping data from the old cluster (that's why we need executables
from the previous version) and importing them into the new cluster. Finally, the old
and the new clusters are swapped and the old one is removed.

Test Plan: Tested on Fedora, upgrading from Postgres 10 to 11

Reviewers: KDE PIM, knauss

Reviewed By: KDE PIM, knauss

Subscribers: asturmlechner, knauss, kde-pim

Tags: KDE PIM

Differential Revision: https://phabricator.kde.org/D21154