Skip to content

[Bug]: Migrating from MySQL to Postgres: syntax error at or near ")" nextcloud.oc_sec_signatory_id_seq #58063

@AdriDevelopsThings

Description

@AdriDevelopsThings

⚠️ This issue respects the following points: ⚠️

Bug description

I'm currently trying to migrate from MySQL to Postgres using the occ db:convert-type feature. I already found other people that have syntax error problems when migrating but for me it looks like the problems have something to do with apps.

I attached the output of the migration log as nextcloud logs at the bottom. The postgresql server log looks like that:

2026-02-04 21:08:56.786 UTC [114265] nextcloud@nextcloud ERROR:  syntax error at or near ")" at character 71
2026-02-04 21:08:56.786 UTC [114265] nextcloud@nextcloud STATEMENT:  SELECT setval('nextcloud.oc_text_sessions_id_seq', (SELECT MAX() FROM ))

Steps to reproduce

  1. Setup nextcloud using MySQL
  2. Setup a Postgres server
  3. Run php occ db:convert-type --clear-schema pgsql <username> <host> <dbname>

Expected behavior

The migration should run without errors.

Nextcloud Server version

32

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Nginx

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 31 to 32)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.zukunft-vieselbach.de"
        ],
        "default_language": "de",
        "default_locale": "de_DE",
        "default_phone_region": "DE",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "32.0.5.0",
        "overwrite.cli.url": "https:\/\/cloud.zukunft-vieselbach.de",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "skeletondirectory": "",
        "maintenance": false,
        "maintenance_window_start": 1,
        "theme": "",
        "loglevel": 2
    }
}

List of activated Apps

Enabled:
  - activity: 5.0.0-dev.0
  - app_api: 32.0.0
  - bruteforcesettings: 5.0.0-dev.0
  - circles: 32.0.0
  - cloud_federation_api: 1.16.0
  - comments: 1.22.0
  - contactsinteraction: 1.13.1
  - dav: 1.34.2
  - federatedfilesharing: 1.22.0
  - files: 2.4.0
  - files_downloadlimit: 5.0.0-dev.0
  - files_pdfviewer: 5.0.0-dev.0
  - files_reminders: 1.5.0
  - files_sharing: 1.24.1
  - files_trashbin: 1.22.0
  - files_versions: 1.25.0
  - firstrunwizard: 5.0.0-dev.0
  - logreader: 5.0.0-dev.0
  - lookup_server_connector: 1.20.0
  - nextcloud_announcements: 4.0.0-dev.0
  - notifications: 5.0.0-dev.0
  - oauth2: 1.20.0
  - password_policy: 4.0.0-dev.0
  - photos: 5.0.0-dev.1
  - privacy: 4.0.0-dev.0
  - profile: 1.1.0
  - provisioning_api: 1.22.0
  - related_resources: 3.0.0-dev.0
  - serverinfo: 4.0.0-dev.0
  - settings: 1.15.1
  - sharebymail: 1.22.0
  - support: 4.0.0-dev.0
  - survey_client: 4.0.0-dev.0
  - systemtags: 1.22.0
  - text: 6.0.1
  - theming: 2.7.0
  - twofactor_backupcodes: 1.21.0
  - twofactor_nextcloud_notification: 6.0.0-dev.0
  - twofactor_totp: 14.0.0
  - updatenotification: 1.22.0
  - user_status: 1.12.0
  - viewer: 5.0.0-dev.0
  - webhook_listeners: 1.3.0
  - workflowengine: 2.14.0
Disabled:
  - admin_audit: 1.22.0
  - dashboard: 7.12.0 (installed 7.4.0)
  - encryption: 2.20.0
  - federation: 1.22.0 (installed 1.14.0)
  - files_external: 1.24.1
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - recommendations: 5.0.0-dev.0 (installed 1.3.0)
  - suspicious_login: 10.0.0-dev.0
  - user_ldap: 1.23.0
  - weather_status: 1.12.0 (installed 1.4.0)

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

Important log is the migration command output:

Clearing schema in new database
Creating schema in new database
 - circles
 - files_pdfviewer
 - files
 - nextcloud_announcements
 - user_ldap
 - firstrunwizard
 - notifications
 - contactsinteraction
 - twofactor_totp
 - comments
 - provisioning_api
 - photos
 - password_policy
 - logreader
 - text
 - twofactor_backupcodes
 - webhook_listeners
 - files_reminders
 - admin_audit
 - privacy
 - systemtags
 - related_resources
 - serverinfo
 - files_trashbin
 - files_sharing
 - bruteforcesettings
 - survey_client
 - files_rightclick
 - federatedfilesharing
 - encryption
 - profile
 - user_status
 - recommendations
 - dav
 - dashboard
 - lookup_server_connector
 - viewer
 - files_downloadlimit
 - support
 - updatenotification
 - files_external
 - files_versions
 - cloud_federation_api
 - theming
 - weather_status
 - settings
 - oauth2
 - workflowengine
 - activity
 - twofactor_nextcloud_notification
 - federation
 - app_api
 - sharebymail
 - suspicious_login
The following tables will not be converted:
oc_ex_event_handlers
oc_ex_speech_to_text
oc_ex_speech_to_text_q
oc_ex_text_processing
oc_ex_text_processing_q
oc_ex_translation
oc_ex_translation_q
oc_file_metadata
Continue with the conversion (y/n)? [n] y
 - oc_accounts
 11/11 [============================] 100% < 1 sec/< 1 sec
 - oc_accounts_data
 155/155 [============================] 100% < 1 sec/< 1 sec
 - oc_activity
chunked query, 2 chunks
 1164/1164 [============================] 100% < 1 sec/< 1 sec
 - oc_activity_mq
    0 [>---------------------------] < 1 sec
 - oc_addressbookchanges
 168/168 [============================] 100% < 1 sec/< 1 sec
 - oc_addressbooks
 8/8 [============================] 100% < 1 sec/< 1 sec
 - oc_appconfig
 209/209 [============================] 100% < 1 sec/< 1 sec
 - oc_appconfig_ex
    0 [>---------------------------] < 1 sec
 - oc_authorized_groups
    0 [>---------------------------] < 1 sec
 - oc_authtoken
 5/5 [============================] 100% < 1 sec/< 1 sec
 - oc_bruteforce_attempts
    0 [>---------------------------] < 1 sec
 - oc_calendar_invitations
    0 [>---------------------------] < 1 sec
 - oc_calendar_reminders
    0 [>---------------------------] < 1 sec
 - oc_calendar_resources
    0 [>---------------------------] < 1 sec
 - oc_calendar_resources_md
    0 [>---------------------------] < 1 sec
 - oc_calendar_rooms
    0 [>---------------------------] < 1 sec
 - oc_calendar_rooms_md
    0 [>---------------------------] < 1 sec
 - oc_calendarchanges
    0 [>---------------------------] < 1 sec
 - oc_calendarobjects
    0 [>---------------------------] < 1 sec
 - oc_calendarobjects_props
    0 [>---------------------------] < 1 sec
 - oc_calendars
 11/11 [============================] 100% < 1 sec/< 1 sec
 - oc_calendars_federated
    0 [>---------------------------] < 1 sec
 - oc_calendarsubscriptions
    0 [>---------------------------] < 1 sec
 - oc_cards
 12/12 [============================] 100% < 1 sec/< 1 sec
 - oc_cards_properties
 73/73 [============================] 100% < 1 sec/< 1 sec
 - oc_circles_circle
 18/18 [============================] 100% < 1 sec/< 1 sec
 - oc_circles_event
 41/41 [============================] 100% < 1 sec/< 1 sec
 - oc_circles_member
 47/47 [============================] 100% < 1 sec/< 1 sec
 - oc_circles_membership
 41/41 [============================] 100%  1 sec/1 sec
 - oc_circles_mount
    0 [>---------------------------] < 1 sec
 - oc_circles_mountpoint
    0 [>---------------------------] < 1 sec
 - oc_circles_remote
    0 [>---------------------------] < 1 sec
 - oc_circles_share_lock
    0 [>---------------------------] < 1 sec
 - oc_circles_token
    0 [>---------------------------] < 1 sec
 - oc_collres_accesscache
    0 [>---------------------------] < 1 sec
 - oc_collres_collections
    0 [>---------------------------] < 1 sec
 - oc_collres_resources
    0 [>---------------------------] < 1 sec
 - oc_comments
    0 [>---------------------------] < 1 sec
 - oc_comments_read_markers
    0 [>---------------------------] < 1 sec
 - oc_dav_absence
    0 [>---------------------------] < 1 sec
 - oc_dav_cal_proxy
    0 [>---------------------------] < 1 sec
 - oc_dav_shares
    0 [>---------------------------] < 1 sec
 - oc_direct_edit
    0 [>---------------------------] < 1 sec
 - oc_directlink
    0 [>---------------------------] < 1 sec
 - oc_ex_apps
    0 [>---------------------------] < 1 sec
 - oc_ex_apps_daemons
    0 [>---------------------------] < 1 sec
 - oc_ex_apps_routes
    0 [>---------------------------] < 1 sec
 - oc_ex_deploy_options
    0 [>---------------------------] < 1 sec
 - oc_ex_occ_commands
    0 [>---------------------------] < 1 sec
 - oc_ex_settings_forms
    0 [>---------------------------] < 1 sec
 - oc_ex_task_processing
    0 [>---------------------------] < 1 sec
 - oc_ex_ui_files_actions
    0 [>---------------------------] < 1 sec
 - oc_ex_ui_scripts
    0 [>---------------------------] < 1 sec
 - oc_ex_ui_states
    0 [>---------------------------] < 1 sec
 - oc_ex_ui_styles
    0 [>---------------------------] < 1 sec
 - oc_ex_ui_top_menu
    0 [>---------------------------] < 1 sec
 - oc_federated_invites
    0 [>---------------------------] < 1 sec
 - oc_federated_reshares
    0 [>---------------------------] < 1 sec
 - oc_file_locks
 46/46 [============================] 100% < 1 sec/< 1 sec
 - oc_filecache
chunked query, 7 chunks
 6687/6687 [============================] 100% 2 secs/2 secs
 - oc_filecache_extended
 990/990 [============================] 100%  1 sec/1 sec
 - oc_files_metadata
 148/148 [============================] 100% < 1 sec/< 1 sec
 - oc_files_metadata_index
 152/152 [============================] 100% < 1 sec/< 1 sec
 - oc_files_reminders
    0 [>---------------------------] < 1 sec
 - oc_files_trash
 65/65 [============================] 100% < 1 sec/< 1 sec
 - oc_files_versions
 834/834 [============================] 100% < 1 sec/< 1 sec
 - oc_flow_checks
    0 [>---------------------------] < 1 sec
 - oc_flow_operations
    0 [>---------------------------] < 1 sec
 - oc_flow_operations_scope
    0 [>---------------------------] < 1 sec
 - oc_group_admin
    0 [>---------------------------] < 1 sec
 - oc_group_user
 30/30 [============================] 100% < 1 sec/< 1 sec
 - oc_groups
 6/6 [============================] 100% < 1 sec/< 1 sec
 - oc_jobs
 55/55 [============================] 100% < 1 sec/< 1 sec
 - oc_known_users
    0 [>---------------------------] < 1 sec
 - oc_login_flow_v2
    0 [>---------------------------] < 1 sec
 - oc_migrations
Skipping migrations table because it was already filled by running the migrations
 - oc_mimetypes
 50/50 [============================] 100% < 1 sec/< 1 sec
 - oc_mounts
 7/7 [============================] 100% < 1 sec/< 1 sec
 - oc_notifications
 49/49 [============================] 100% < 1 sec/< 1 sec
 - oc_notifications_pushhash
 1/1 [============================] 100% < 1 sec/< 1 sec
 - oc_notifications_settings
 11/11 [============================] 100% < 1 sec/< 1 sec
 - oc_oauth2_access_tokens
    0 [>---------------------------] < 1 sec
 - oc_oauth2_clients
    0 [>---------------------------] < 1 sec
 - oc_open_local_editor
    0 [>---------------------------] < 1 sec
 - oc_photos_albums
    0 [>---------------------------] < 1 sec
 - oc_photos_albums_collabs
    0 [>---------------------------] < 1 sec
 - oc_photos_albums_files
    0 [>---------------------------] < 1 sec
 - oc_preferences
 299/299 [============================] 100% < 1 sec/< 1 sec
 - oc_preferences_ex
    0 [>---------------------------] < 1 sec
 - oc_privacy_admins
    0 [>---------------------------] < 1 sec
 - oc_profile_config
 11/11 [============================] 100% < 1 sec/< 1 sec
 - oc_properties
    0 [>---------------------------] < 1 sec
 - oc_ratelimit_entries
    0 [>---------------------------] < 1 sec
 - oc_reactions
    0 [>---------------------------] < 1 sec
 - oc_recent_contact
    0 [>---------------------------] < 1 sec
 - oc_schedulingobjects
    0 [>---------------------------] < 1 sec
 - oc_sec_signatory
    0 [>---------------------------] < 1 sec
 - oc_share
 41/41 [============================] 100% < 1 sec/< 1 sec
 - oc_share_external
    0 [>---------------------------] < 1 sec
 - oc_shares_limits
    0 [>---------------------------] < 1 sec
 - oc_storages
 12/12 [============================] 100% < 1 sec/< 1 sec
 - oc_storages_credentials
    0 [>---------------------------] < 1 sec
 - oc_systemtag
    0 [>---------------------------] < 1 sec
 - oc_systemtag_group
    0 [>---------------------------] < 1 sec
 - oc_systemtag_object_mapping
    0 [>---------------------------] < 1 sec
 - oc_taskprocessing_tasks
    0 [>---------------------------] < 1 sec
 - oc_text2image_tasks
    0 [>---------------------------] < 1 sec
 - oc_text_documents
 1/1 [============================] 100% < 1 sec/< 1 sec
 - oc_text_sessions
 3/3 [============================] 100% < 1 sec/< 1 sec
 - oc_text_steps
 39/39 [============================] 100% < 1 sec/< 1 sec
 - oc_textprocessing_tasks
    0 [>---------------------------] < 1 sec
 - oc_trusted_servers
    0 [>---------------------------] < 1 sec
 - oc_twofactor_backupcodes
    0 [>---------------------------] < 1 sec
 - oc_twofactor_providers
 14/14 [============================] 100% < 1 sec/< 1 sec
 - oc_twofactor_tnn_tokens
    0 [>---------------------------] < 1 sec
 - oc_twofactor_totp_secrets
 1/1 [============================] 100% < 1 sec/< 1 sec
 - oc_user_status
 7/7 [============================] 100% < 1 sec/< 1 sec
 - oc_user_transfer_owner
    0 [>---------------------------] < 1 sec
 - oc_users
 11/11 [============================] 100% < 1 sec/< 1 sec
 - oc_vcategory
    0 [>---------------------------] < 1 sec
 - oc_vcategory_to_object
    0 [>---------------------------] < 1 sec
 - oc_webauthn
    0 [>---------------------------] < 1 sec
 - oc_webhook_listeners
    0 [>---------------------------] < 1 sec
 - oc_whats_new
 40/40 [============================] 100% < 1 sec/< 1 sec

In ExceptionConverter.php line 62:

  An exception occurred while executing a query: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"
  LINE 1: ...l('nextcloud.oc_text_sessions_id_seq', (SELECT MAX() FROM ))
                                                                       ^


In Exception.php line 24:

  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"
  LINE 1: ...l('nextcloud.oc_text_sessions_id_seq', (SELECT MAX() FROM ))
                                                                       ^


In Connection.php line 71:

  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"
  LINE 1: ...l('nextcloud.oc_text_sessions_id_seq', (SELECT MAX() FROM ))
                                                                       ^


db:convert-type [--port PORT] [--password PASSWORD] [--clear-schema] [--all-apps] [--chunk-size CHUNK-SIZE] [--] <type> <username> <hostname> <database>

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmap32-feedbackbug

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions