Hi everyone,
A bit more information about the PostgreSQL plugin 6.0 and 6.1 that includes an upgrade of the DB schema.
For simple systems with a single Orthanc and “small database”, the process is fully automatic and you should not worry.
However, after applying this upgrade on more complex systems, we are sharing these lessons learned (also available in the book):
When upgrading from revision 1 to revision 2, the upgrade might take quite some time. E.g, we have observed the upgrade taking 17 minutes on a DB with 300.000 studies and 150 millions instances. Orthanc will not respond during the upgrade. Therefore, if you have enabled autohealing (automatic restart in case Orthanc is not responsive), you should likely disable it during the first start with the PostgreSQL plugin v6.0.
Also note that, if you have multiple containers connected to the same DB, all containers will try to acquire an exclusive lock to perform the upgrade of the DB. Only one of them will actually perform the upgrade. Also note that you should not perform a rolling updates of the Orthanc containers when performing a DB upgrade. All Orthanc containers should use the same version of the plugin, the one that is compatible with the current revision.
Therefore, in complex setups, it might be simpler/safer to simply shut-down the Orthanc containers, perform the upgrade manually and then, restart the Orthanc containers with the newest version of the plugin.
To upgrade manually from revision 1 to revision 2, one might run this procedure on the existing DB:
$ wget https://orthanc.uclouvain.be/hg/orthanc-databases/raw-file/default/PostgreSQL/Plugins/SQL/Upgrades/Rev1ToRev2.sql
$ wget https://orthanc.uclouvain.be/hg/orthanc-databases/raw-file/default/PostgreSQL/Plugins/SQL/PrepareIndex.sql
$ psql -U postgres -f Rev1ToRev2.sql
$ psql -U postgres -f PrepareIndex.sql
This procedure is identical to the one performed automatically by Orthanc when it detects that an upgraded is required.
HTH,
Alain.