SQL error and failure to update from nc19 to 20


We have upgraded our Nextcloud version from 19.0.3 to 19.0.13,
and trying to upgrade from 19.0.13 to 20 but getting this error :

:/var/www/html/cloudrive# sudo -u www-data 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
Setting log level to debug
Updating database schema
Doctrine\DBAL\Exception\UniqueConstraintViolationException: An exception occurred while executing ‘INSERT INTO oc_storages_credentials (user, identifier, credentials) VALUES(?, ?, ?)’ with params ["", “password::global”, “557377e778c414a0d0b325596d45880078c5ddc9219259de6f11cdd5ed52dc9a7e713c99e1b85d0f6eb65630e5f93146|200ecf4839a51daf900a1a89f8935704|42b12392157f66bb420e68c5435d1dc58f84e9bf054692a2ab1bd8608ff62d1bc3ecb879f82adc2ef00bc55881f07bc27163f6faa5d847cd6aa777c2b2dacc73|2”]:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ‘password::global’ for key ‘stocred_ui’
Update failed
Maintenance mode is kept active
Resetting log level

You can try if the internal repair mechanism fixes the issue:

sudo -u www-data php occ maintenance:repair -vv

And if that does not work, you can check the table manually in the database. It should be similar to similar fixes here: Integrity constraint violation: 1062 Duplicate entry '-' for key 'pw_password_revision_index'

If you plan to change the database manually, please backup the database before. You can get things wrong and in that case you want to restore the latest working version easily.