NC20: Migration from mariadb to postgresql failed with invalid syntax

Nextcloud version : 20.0.4.0
Operating system and version : Slackware 14.2
Apache or nginx version : nginx 1.12.2
PHP version : 7.4.13

The issue you are facing:

I would like to migrate my nextcloud installation from MariaDB to PostgreSQL. So I executed the occ db:convert-type command below.

At some point, I got the following error:

In AbstractPostgreSQLDriver.php line 54:                                                                                                
                                                                                                                                        
  An exception occurred while executing 'SELECT setval('oc_text_documents_id_seq', (SELECT MAX() FROM ))':                              
                                                                                                                                        
  SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near ")"                                                                  
  LINE 1: ...ECT setval('oc_text_documents_id_seq', (SELECT MAX() FROM ))                                                               
                                                                     ^     

This error is triggered in 3 different files (see attached file).
https://imagebin.ca/v/5m3pvWer1eWu

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

Steps to replicate it:

  1. $ cd /var/www/nextcloud
  2. $ sudo -u nobody php occ db:convert-type --all-apps --port 5432 --password “secret” pgsql nextcloud 127.0.0.1 nextcloud
  3. Type < enter >

The output of your Nextcloud log in Admin > Logging:

N/A

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

$CONFIG = array (
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'xxx',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'overwrite.cli.url' => 'xxx',
  'dbtype' => 'mysql',
  'version' => '20.0.4.0',
  'logtimezone' => 'UTC',
  'installed' => true,
  'loglevel' => 0,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'timeout' => 1.5,
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_from_address' => 'xxx',
  'mail_domain' => 'xxx',
  'mail_smtphost' => 'xxx',
  'mail_smtpport' => '587',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'theme' => '',
  'dbname' => 'nextcloud',
  'dbhost' => '127.0.0.1:3306',
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'mysql.utf8mb4' => true,
  'updater.release.channel' => 'stable',
  'trashbin_retention_obligation' => 'auto, 3',
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'encryption.legacy_format_support' => false,
  'encryption.key_storage_migrated' => false,
);

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

N/A
1 Like

You should submit a bug report to https://github.com/nextcloud/server/issues
I can reproduce it too.

Somebody reported this in #24884: Syntax Error on db:convert-type - conversion MariaDB->PostgreSQL | NC 20. A workaround exists.