constraint collision when installing Office app in Nextcloud

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 31.0.6
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 22.04.5
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.52
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • traefik 3.4
  • PHP version (e.g, 8.3):
    • 8.3
  • MySQL Server Version
    • 8.0.42-0ubuntu0.22.04.1 (Ubuntu)
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • When I tried to install the “Nextcloud Office” App
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Archive
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

I tried installing the Nextcloud Office App using the App Store in the Browser but I also tried installing the app via OCC. It returns the Error:

Es ist ein Fehler bei der Anfrage aufgetreten. Es kann nicht fortgefahren werden.
Index name “schedulobj_lastmodified_idx” for table “oc_schedulingobjects” collides with the constraint on table “oc_calendarobjects”.

Steps to replicate it (hint: details matter!):

  1. Open https:///settings/apps/discover/richdocuments
  2. Click Install

Log entries

Nextcloud

{"reqId":"wMAku4Tx6wSrVlSbmSkS","level":0,"time":"2025-06-24T14:23:33+00:00","remoteAddr":"1.2.3.4","user":"admin","app":"richdocuments","method":"POST","url":"/settings/apps/enable","message":"- Checking target database schema","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0","version":"31.0.6.2","data":{"app":"richdocuments"}}

{"reqId":"wMAku4Tx6wSrVlSbmSkS","level":3,"time":"2025-06-24T14:23:33+00:00","remoteAddr":"1.2.3.4","user":"admin","app":"settings","method":"POST","url":"/settings/apps/enable","message":"could not enable apps","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0","version":"31.0.6.2","exception":{"Exception":"InvalidArgumentException","Message":"Index name \"schedulobj_lastmodified_idx\" for table \"oc_schedulingobjects\" collides with the constraint on table \"oc_calendarobjects\".","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":429,"function":"ensureUniqueNamesConstraints","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":387,"function":"migrateSchemaOnly","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/Installer.php","line":105,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/apps/settings/lib/Controller/AppSettingsController.php","line":531,"function":"installApp","class":"OC\\Installer","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":200,"function":"enableApps","class":"OCA\\Settings\\Controller\\AppSettingsController","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":114,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":161,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":307,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1040,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":24,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/DB/MigrationService.php","Line":677,"message":"could not enable apps","exception":{},"CustomMessage":"could not enable apps"}}

Configuration

Nextcloud

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "skeletondirectory": "",
        "htaccess.RewriteBase": "\/",
        "trusted_domains": [
            "cloud.example.com",
            "cloud-test.example.com"
        ],
        "allow_local_remote_servers": true,
        "maintenance": false,
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "enable_previews": false,
        "default_phone_region": "DE",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "31.0.6.2",
        "overwrite.cli.url": "http:\/\/localhost",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "maintenance_window_start": 1,
        "loglevel": 0,
        "log_type": "file",
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "theme": "",
        "twofactor_enforced": "false",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [],
        "mail_smtpsecure": "ssl",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "app_install_overwrite": []
    }
}

Apps

Enabled:
  - activity: 4.0.0
  - admin_audit: 1.21.0
  - app_api: 5.0.2
  - bruteforcesettings: 4.0.0
  - calendar: 5.3.3
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - collectives: 2.18.0
  - comments: 1.21.0
  - contacts: 7.1.3
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - deck: 1.15.1
  - drawio: 3.1.0
  - federatedfilesharing: 1.21.0
  - federation: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - impersonate: 2.0.0
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - mail: 5.1.4
  - nextcloud_announcements: 3.0.0
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - password_policy: 3.0.0
  - photos: 4.0.0-dev.1
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - spreed: 21.1.0
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - tasks: 0.16.1
  - text: 5.0.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - twofactor_totp: 13.0.0-dev.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - bookmarks: 15.1.0 (installed 15.1.0)
  - encryption: 2.19.0
  - files_external: 1.23.0
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - richdocuments: 8.7.1
  - sociallogin: 6.0.2 (installed 6.0.2)
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - user_ldap: 1.22.0

collides with the constraint on table \"oc_calendarobjects\

Anything unusual about your installation? Ever done any manual db work on it for example?

The calendarobjects table doesn’t have any conflicts that should cause this that I see offhand.

Take a look at your database and see what the oc_calendarobjects table has in the way of indexes. Since you’re on v31 you can probably use occ db:schema:export and search until you find the section for oc_calendarobjects. Then find the indexes section within it.

It (should) look something like the below, but post yours if its different.

  - oc_calendarobjects:
    - columns:
[...]
    - indexes:
      - PRIMARY:
        - name: PRIMARY
        - columns:
          - id
        - unique: true
        - primary: true
        - flags:
        - options:
      - calobj_clssfction_index:
        - name: calobj_clssfction_index
        - columns:
          - classification
        - unique: false
        - primary: false
        - flags:
        - options:
      - calobjects_index:
        - name: calobjects_index
        - columns:
          - calendarid
          - calendartype
          - uri
        - unique: true
        - primary: false
        - flags:
        - options:

Hi @jtr
Thank you very much for having a look at my issue. Regarding your question whether there is someting unusual: I have been updating my nextcloud for quite a few years now, so it’s not a new installation, but I can’t remember doing manual database tinkering ever.
Thanks to your hint I now believe that I have an additional index in oc_calendarobjects that doesn’t belong there

user@nextcloud:/var/www/nextcloud# sudo -u www-data /bin/php8.3 occ db:schema:export
[...]
  - oc_calendarobjects:
[...]
    - indexes:
      - PRIMARY:
        - name: PRIMARY
        - columns:
          - id
        - unique: true
        - primary: true
        - flags:
        - options:
      - calobj_clssfction_index:
        - name: calobj_clssfction_index
        - columns:
          - classification
        - unique: false
        - primary: false
        - flags:
        - options:
      - calobjects_index:
        - name: calobjects_index
        - columns:
          - calendarid
          - calendartype
          - uri
        - unique: true
        - primary: false
        - flags:
        - options:
      - schedulobj_lastmodified_idx:
        - name: schedulobj_lastmodified_idx
        - columns:
          - lastmodified
        - unique: false
        - primary: false
        - flags:
        - options:

Do you have an idea how to safely repair that?

we’ve seen similar issues in the snap… very old version reaching v 31 were not upgrading the database to DYNAMIC effectively… I’m assuming this could be relevant? see Warning message to "change row format to DYNAMIC" -- Nextcloud snap update to Nextcloud Hub 10 (31.0.2) · Issue #3123 · nextcloud-snap/nextcloud-snap · GitHub

now I know you’re not running the snap… but under the hood its all the same right?

Hi,

das Problem entsteht durch einen Index-Namen-Konflikt in der Datenbank, der verhindert, dass die Office-App korrekt installiert wird. Es sieht so aus, als ob ein Index schedulobj_lastmodified_idx in der Tabelle oc_schedulingobjects mit einem bestehenden Constraint in oc_calendarobjects kollidiert.

Einige Lösungsvorschläge:

  • PrĂĽfe, ob die Datenbank-Schemata vor der Installation sauber sind und keine Reste von vorherigen Installationen oder fehlgeschlagenen Migrationen vorhanden sind.
  • Ein möglicher Workaround ist, manuell den Index oder Constraint in der Datenbank umzubenennen oder zu löschen, wenn du dich mit MySQL auskennst (bitte vorher Backup machen!).
  • Alternativ könntest du versuchen, die App ĂĽber die Kommandozeile mit occ mit --skip-migrations zu installieren, falls du weiĂźt, was du tust.
  • Eventuell gibt es auch einen Bugreport dazu, deshalb lohnt sich ein Blick ins Nextcloud GitHub oder Forum fĂĽr ähnliche Fälle.
    Wenn du unsicher bist, poste am besten mal die Ausgabe von occ db:structure:validate oder die kompletten Migrationslogs.

Viel Erfolg!

@scubamuc Thanks for the input. If I remember correctly, I might have started my nextcloud instance as a snap install many years ago and then I migrated to the archive version. I followed your link and had a look at the suggestions there, but I can’t upgrade the snap package since I’ve migrated to the package install. Do you have any suggestions how to fix the error in my case?

that was my assumption:

but considering this is a long standing install migrated to the package install, the thought that it may be related came to mind :thinking:. not being a dev though and the mention of possible relevancy might help issue resolution for the technical folks here… suggest we wait for tech folks?

meanwhile, considering the suggestions by @Charles_R_Howard, you could try some maintenance jobs using OCC management console;

occ files:repair-tree -n -vvv
occ files:scan --all -n -vvv
occ files:scan-app-data -n -vvv
occ files:cleanup -n -vvv;