Upgrade or Mail App Update Problem

Nextcloud version (eg, 20.0.5): 22.2.3.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 21.10
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.48-3.1ubuntu3.4
PHP version (eg, 7.4): 8.0
Mail App Version: 1.12.0

The issue you are facing:

My implementation is stuck. I cannot upgrade nor run the site.

When updating apps via occ, several apps were successfully updated, but mail failed. I believe I got the same error the first time, but when I try to update apps now with occ app:update --all I get a message that says:

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

When I try to run upgrade via occ upgrade I get the following:

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
Updated database
Updating <mail> ...
An unhandled exception has been thrown:
Error: Call to undefined method OC\DB\SchemaWrapper::getDatabasePlatform() in /var/www/nextcloud/apps/mail/lib/Migration/Version1130Date20220412111833.php:122
Stack trace:
#0 /var/www/nextcloud/lib/private/DB/MigrationService.php(532): OCA\Mail\Migration\Version1130Date20220412111833->changeSchema()
#1 /var/www/nextcloud/lib/private/DB/MigrationService.php(425): OC\DB\MigrationService->executeStep()
#2 /var/www/nextcloud/lib/private/legacy/OC_App.php(1010): OC\DB\MigrationService->migrate()
#3 /var/www/nextcloud/lib/private/Updater.php(352): OC_App::updateApp()
#4 /var/www/nextcloud/lib/private/Updater.php(264): OC\Updater->doAppUpgrade()
#5 /var/www/nextcloud/lib/private/Updater.php(132): OC\Updater->doUpgrade()
#6 /var/www/nextcloud/core/Command/Upgrade.php(241): OC\Updater->upgrade()
#7 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OC\Core\Command\Upgrade->execute()
#8 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run()
#9 /var/www/nextcloud/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#10 /var/www/nextcloud/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#11 /var/www/nextcloud/lib/private/Console/Application.php(209): Symfony\Component\Console\Application->run()
#12 /var/www/nextcloud/console.php(99): OC\Console\Application->run()
#13 /var/www/nextcloud/occ(11): require_once('...')
#14 {main}

If I turn off maintenance mode, the website says:

App update required
The following apps will be updated:
Mail (mail)
Please make sure that the database, the config folder and the data folder have been backed up before proceeding.

with a Start Update button. If I click that Start Update button, I get:

Update to 22.2.3
An error occurred.

Detailed logs 
Preparing update
Set log level to debug
Turned on maintenance mode
Repair step: Repair MySQL collation
Repair info: All tables already have the correct collation -> nothing to do
Repair step: Repair SQLite autoincrement
Repair step: Copy data from accounts table when migrating from ownCloud
Repair step: Drop account terms table when migrating from ownCloud
Updating database schema
Updated database
An error occurred

The log file says:

{
  "reqId": "<request_id>",
  "level": 3,
  "time": "<time_stamp>",
  "remoteAddr": "v.x.y.z",
  "user": "--",
  "app": "PHP",
  "method": "GET",
  "url": "/core/ajax/update.php?requesttoken=<request_token>",
  "message": "Error: Call to undefined method OC\\DB\\SchemaWrapper::getDatabasePlatform() at /var/www/nextcloud/apps/mail/lib/Migration/Version1130Date20220412111833.php#122",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.72 Safari/537.36",
  "version": "22.2.3.0"
}

Is this the first time you’ve seen this error? (Y/N): Yes

Steps to replicate it:

  1. Run occ upgrade

– or —

  1. occ maintenance:mode --off
  2. Visit the site
  3. Click Start Update

The output of your Nextcloud log in Admin > Logging:
The site is inaccessible

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'instanceid' => '<instance_id>',
  'passwordsalt' => '<password_salt>',
  'secret' => '<secret>',
  'trusted_domains' => 
  array (
    0 => 'cloud.<domain>.com',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '22.2.3.0',
  'overwrite.cli.url' => 'https://cloud.<domain>.com',
  'dbname' => 'nextcloud',
  'dbhost' => '<dbhost>',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '<db_user>',
  'dbpassword' => '<db_password>',
  'installed' => true,
  'maintenance' => true,
  'theme' => '',
  'loglevel' => 0,
  'default_phone_region' => '<default_phone_region>',
);

The output of your Apache/nginx/system log in /var/log/____:
N/A

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.
Pastebin Log

1 Like

Just got the exact same error. Don’t know how to fix it. But you can disable the mail app, at least your nextcloud will be back online.

This error occurs on NC instances with version < 22.2.4. Details are at ISchemaWrapper.getDatabasePlatform requires Nextcloud 22.2.4 by kesselb · Pull Request #6641 · nextcloud/mail · GitHub

I was able to solve the problem by running:
sudo -u www-data php ./updater/updater.phar
in NC_HOME (I used sudo -u www-data because www-data own the NC installation).

It upgraded NC from 22.2.3.0 to 22.2.8.1 which, according to @SysKeeper’s comment, is above the required 122.2.4`.

Thank you for the help @SysKeeper.

1 Like

Thanks @ryukenhin. I hadn’t thought to do that; it probably would have saved me a big headache. I was able to fix it without disabling the mail app but running <NC_HOME>/updater/updater.phar. It was much more verbose (and I assume involved) than occ upgrade, so somehow it got around the problem.