On Mail Enable I get, "The column 'signature' on table 'oc_mail_accounts' already exists'"

Nextcloud version (eg, 20.0.5): 25.0.3
Operating system and version (eg, Ubuntu 20.04): Synology DSM 7.1.1-42962
Apache or nginx version (eg, Apache 2.4.25): ?
PHP version (eg, 7.4): ?
Docker images: nextcloud:latest and mariadb:latest

The issue you are facing:
When I try to Enable the Mail app, I get the error “The column ‘signature’ on table ‘oc_mail_accounts’ already exists’”

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

Steps to replicate it:

  1. Download and Enable the Mail app

The output of your Nextcloud log in Admin > Logging:

[settings] Error: Doctrine\DBAL\Schema\SchemaException: The column 'signature' on table 'oc_mail_aliases' already exists. at <<closure>>

 0. /var/www/html/3rdparty/doctrine/dbal/src/Schema/Table.php line 473
    Doctrine\DBAL\Schema\SchemaException::columnAlreadyExists("oc_mail_aliases", "signature")
 1. /var/www/html/3rdparty/doctrine/dbal/src/Schema/Table.php line 355
    Doctrine\DBAL\Schema\Table->_addColumn(Doctrine\DBAL\Schema\Column {})
 2. /var/www/html/custom_apps/mail/lib/Migration/Version1100Date20210317164707.php line 25
    Doctrine\DBAL\Schema\Table->addColumn("signature", "text", [false,1024,""])
 3. /var/www/html/lib/private/DB/MigrationService.php line 445
    OCA\Mail\Migration\Version1100Date20210317164707->changeSchema(OC\Migration\SimpleOutput {}, Closure {}, ["oc_"])
 4. /var/www/html/lib/private/DB/MigrationService.php line 408
    OC\DB\MigrationService->migrateSchemaOnly("latest")
 5. /var/www/html/lib/private/Installer.php line 153
    OC\DB\MigrationService->migrate("latest", true)
 6. /var/www/html/apps/settings/lib/Controller/AppSettingsController.php line 451
    OC\Installer->installApp("mail")
 7. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 225
    OCA\Settings\Controller\AppSettingsController->enableApps(["mail"], [])
 8. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 133
    OC\AppFramework\Http\Dispatcher->executeController(OCA\Settings\Con ... {}, "enableApps")
 9. /var/www/html/lib/private/AppFramework/App.php line 172
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Settings\Con ... {}, "enableApps")
10. /var/www/html/lib/private/Route/Router.php line 298
    OC\AppFramework\App::main("OCA\\Settings\\ ... r", "enableApps", OC\AppFramework\ ... {}, ["settings.AppSettings.enableApps"])
11. /var/www/html/lib/base.php line 1047
    OC\Route\Router->match("/settings/apps/enable")
12. /var/www/html/index.php line 36
    OC::handleRequest()

POST /settings/apps/enable
from 172.24.0.1 by dean at 2023-02-17T08:05:26+00:00

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'oc6ijn61qy8u',
  'passwordsalt' => 'gEYOj0ZSLlcR8XxWxrnsmovY00G3mS',
  'secret' => 'd1ErUf0V9JgbXW0AZpkIFnZ+gJKOCasBEALx7scbAv3UuPGF',
  'trusted_domains' => 
  array (
    0 => '192.168.101.21:8081',
    1 => 'nextcloud.xyz.com',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '25.0.3.2',
  'overwrite.cli.url' => 'https://nextcloud.xyz.com',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'abc',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => 'dean',
  'mail_domain' => 'xyz.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => 'dean@xyz.com',
  'mail_smtppassword' => 'def',
);

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

I could not figure out how to get the file out.  It would not show up in the text editor.

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.

I could not find this file either.

Docker Compose

version: '2'

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - /volume1/docker/nextcloud-mariadb/database:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=
      - MYSQL_PASSWORD=
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8081:80
    links:
      - db
    volumes:
      - /volume1/docker/nextcloud-mariadb/config:/var/www/html
    environment:
      - MYSQL_PASSWORD=
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db


Similar error here, “Database error when running migration XXXX Date XXXXXXX for app mail The column ‘provisioning_id’ on table ‘oc_mail_accounts’ already exists.”

Mail App: v2.2.3
Nextcloud: v25.0.3
Nextcloud Security & setup warnings: All checks passed
OS: QTS 5.0 (Qnap)
Apache: 8.0
PHP: 8.0.16
DB: MariaDB 10.4.7.0.0

I am getting the previous error when installing through the command line:

php occ app:install mail
Error: Database error when running migration 1100Date20210419080523 for app mail
The column 'provisioning_id' on table 'oc_mail_accounts' already exists.

I deleted the problematic column in the table ‘oc_mail_accounts’ and the installation succeeded without any problem, I recommend you do the same and try again. Algo, you might have to do that for each problematic column until you get a successful installation. In each try, you have to -‘delete’ the broken mail app because nextcloud might report it as already being installed.

php occ app:install mail
mail 2.2.3 installed
mail enabled

:+1:

I’m a nube at this. What tool did you use to run the sql commands to drop the column? I’ve tried a couple of graphical tools: DBeaver and Beekeeper Studio but have not been successful at making a connection. I’m trying to connect to the IP address of the synology where the docker container is running, using the user name and password and database specified in my docker compose file on port 3306. I know sql, but have not been able to make a connection. Thanks!