[Bug]: Cannot update mail app : Doctrine\DBAL\Schema\SchemaException: The table with name 'nextcloud.oc_mail_local_messages' already exists.
⚠️ This issue respects the following points: ⚠️
- [X] This is a bug, not a question or a configuration/webserver/proxy issue.
- [X] This issue is not already reported on Github (I've searched it).
- [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- [X] I agree to follow Nextcloud's Code of Conduct.
Bug description
The issue is as follows:
I have upgraded from Nextcloud v20.0.14 to 21.0.9. The update went smoothly, no errors. after the upgrade was complete i was prompted to update the mail app I tried to update and i get this error
Doctrine\DBAL\Schema\SchemaException: The table with name 'nextcloud.oc_mail_local_messages' already exists.
`Update to 21.0.9 Doctrine\DBAL\Schema\SchemaException: The table with name 'nextcloud.oc_mail_local_messages' already exists.
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
Doctrine\DBAL\Schema\SchemaException: The table with name 'nextcloud.oc_mail_local_messages' already exists.
The update was unsuccessful. Please report this issue to the Nextcloud community.`
I've renamed the table and tried again, then i get the same type of error but this time it complains about oc_mail_attachments that it has the same column name local_message_id I've renamed this as well, and tried again, after which i get this error :
Setting log level to debug
Updating database schema
Updated database
Updating
I could bypass it by disabling the mail app from console
I run on a Ubuntu 18.0.4 LTS with Mysql 8.0 and the nextcloud is a webserver on apache2
Steps to reproduce
- use version 20.0.14
- update to 21.0.9
- update mail
Expected behavior
to work, for the mail app update to work
Installation method
Web installer on a VPS or web space
Operating system
Debian/Ubuntu
PHP engine version
PHP 7.3
Web server
Apache (supported)
Database engine version
MySQL
Is this bug present after an update or on a fresh install?
Updated to a major version (ex. 22.2.3 to 23.0.1)
Are you using the Nextcloud Server Encryption module?
No response
What user-backends are you using?
- [X] Default user-backend (database)
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other
Configuration report
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
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"192.168.0.2",
"mx.indrumari-juridice.eu"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "21.0.9.1",
"overwrite.cli.url": "http:\/\/192.168.0.2\/nextcloud",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"mail_smtpmode": "smtp",
"mail_smtpsecure": "ssl",
"mail_sendmailmode": "smtp",
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtpauthtype": "PLAIN",
"mail_smtpauth": 1,
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpport": "465",
"mail_smtpname": "***REMOVED SENSITIVE VALUE***",
"mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
"maintenance": true,
"theme": "",
"loglevel": 1,
"app_install_overwrite": [
"calendar"
],
"memcache.local": "\\OC\\Memcache\\APCu",
"updater.secret": "***REMOVED SENSITIVE VALUE***"
}
}
List of activated Apps
Console has to be executed with the user that owns the file config/config.php
Current user id: 0
Owner id of config.php: 33
Try adding 'sudo -u nextcloud/server#33' to the beginning of the command (without the single quotes)
If running with 'docker exec' try adding the option '-u 33' to the docker command (without the single quotes)
root@mx:/var/www/nextcloud# sudo -u www-data php occ app:list
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
Enabled:
- accessibility: 1.7.0
- activity: 2.14.3
- admin_audit: 1.11.0
- announcementcenter: 5.0.1
- bruteforcesettings: 2.4.0
- calendar: 3.3.0
- cloud_federation_api: 1.4.0
- comments: 1.11.0
- contacts: 4.1.0
- contactsinteraction: 1.2.0
- dashboard: 7.1.0
- dav: 1.17.1
- event_update_notification: 1.4.0
- federatedfilesharing: 1.11.0
- federation: 1.11.0
- files: 1.16.0
- files_external: 1.12.1
- files_pdfviewer: 2.1.1
- files_rightclick: 1.0.0
- files_sharing: 1.13.1
- files_trashbin: 1.11.0
- files_versions: 1.14.0
- files_videoplayer: 1.10.0
- firstrunwizard: 2.10.0
- logreader: 2.6.0
- lookup_server_connector: 1.9.0
- mail: 1.11.7
- metadata: 0.16.0
- nextcloud_announcements: 1.10.0
- notes: 4.3.1
- notifications: 2.9.0
- oauth2: 1.9.0
- onlyoffice: 7.3.2
- password_policy: 1.11.0
- photos: 1.3.0
- privacy: 1.5.0
- provisioning_api: 1.11.0
- quicknotes: 0.7.3
- recommendations: 1.0.0
- richdocuments: 4.2.6
- richdocumentscode: 21.11.402
- serverinfo: 1.11.0
- settings: 1.3.0
- sharebymail: 1.11.0
- spreed: 11.3.6
- support: 1.4.0
- survey_client: 1.9.0
- systemtags: 1.11.0
- tasks: 0.14.4
- text: 3.2.0
- theming: 1.12.0
- twofactor_backupcodes: 1.10.0
- updatenotification: 1.11.0
- user_status: 1.1.1
- viewer: 1.5.0
- weather_status: 1.1.0
- workflowengine: 2.3.1
Disabled:
- encryption
- groupfolders: 8.2.3
- impersonate: 1.7.0
- user_ldap
Nextcloud Signing status
No response
Nextcloud Logs
No response
Additional info
No response
Sounds like the migration was partly run. Then the second run failed.
That was the only app that was requiring to update, after the migration completed, but i couldn't finish the update because of the errors regarding to the table and then the fields mentioned above.
The tables did not have any info inside them, as the email plugin was never used from what i know of ( nobody complained so far ).
The option to continue the migration was to disable the app and continue. After disabling the app and exiting maintenance mode, Nextcloud started without a hitch, and i could see the mail app in the list of apps, and it said that it requires an update. I did not risk it, and i just uninstalled it for now.
I can confirm this bug, I had to disable the mail app to get back into nextcloud.
Sorry for the trouble. Most of the time, this problem occurs when a newer version of the app was installed and then a rollback to an older version was done. If you then update the newer version again, we try to run the migration, but the table already exists, which leads to an undefined state.