SQL error during upgrade

I’m seeking help trying to solve a problem that occurs when upgrading my NC 13.0.6 instance to 13.0.7 or 14.0.2 (attempted to do both).

While executing php occ upgrade I reproducibly see this error:

www-data@[...]:/var/nextcloud$ php occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Set log level to debug
Turned on maintenance mode
Updating database schema
Updated database
[...]
Checking for update of app workflowengine in appstore
Checked for update of app "workflowengine" in appstore
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SHOW search_path':

SQLSTATE[25P02]: In failed sql transaction: 7 ERROR:  current transaction is aborted, commands ignored until end of transaction block
Update failed

I recently converted the database from MySQL to Postgres using the occ db:convert-type command. Had no problems since then until now.

I can psql into the Postgres cluster as user cloud all right and issue show search_path; without problems.

This is on a VServer for which I have full administrative permissions.

Interestingly, as pointed out above, this even occurs when performing the upgrade from 13.0.6 to 13.0.7.

Thanks!

I was able to figure it out – here’s how, just in case someone else has this problem in the future.

The solution was to watch the Postgres log file during occ upgrade, which attempted to recreate tables that already existed:

  • oc_oauth2_clients
  • oc_oauth2_accesstokens
  • oc_flow_checks
  • oc_flow_operations
Postgres log

ERROR:  relation “oc_oauth2_clients” already exists
ERROR:  current transaction is aborted, commands ignored until end of transaction block
ERROR:  relation “oc_oauth2_access_tokens” already exists
ERROR:  current transaction is aborted, commands ignored until end of transaction block

I manually dropped these tables from the database, and everything went smoothly thereafter.

It occurred to me that there were error messages about not being able to upgrade the oauth2 app during previous upgrades, so maybe the schema got corrupted somewhere along the way. I should also note that this used to be an OwnCloud installation which I ‘upgraded’ to NC a while ago.