Migration from postgres to mysql error

Hello

A little history, It’s been owncloud 9 few mouths ago, then I migrated to nextcloud, then upgraded to nextcloud 10 and now 10.0.3

So it’s running on OS X with postgres and I’d like to move now over Ubuntu with memcache optimisation and etc. but everything is fine instead of error during moving to MariaDB 10.1 ( Mysql )

bash-3.2# sudo -u _www php occ db:convert-type --password XXXXXX --all-apps mysql nextcloud 212.XX.35.XX nextcloud
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
Creating schema in new database
The following tables will not be converted:
oc_documents_invite
oc_documents_member
oc_documents_op
oc_documents_revisions
oc_documents_session
oc_lucene_status
Continue with the conversion (y/n)? [n] y
oc_activity
chunked query, 857 chunks
  60000/856518 [=>--------------------------]   7%

  [Doctrine\DBAL\Exception\UniqueConstraintViolationException]
  An exception occurred while executing 'INSERT INTO `oc_activity` (`activity_id`, `timestamp`, `priority`, `type`, `user`, `affecteduser`, `app`, `subject`, `subjectparams`, `message`, `messageparams`, `file`, `link`,
  `object_type`, `object_id`) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [1267692, 1471968661, 30, "file_created", "isobel.gordon", "eric.freeman", "files", "created_by", "[{\"454756\":\"\\\/Sales
  Team\\\/XXXX\\\/20XX Deals\\\/XXXXX X XXXX\\\/XXXXXX\"},\"XXXXXX\"]", "", "[]", "\/Sales Team\/Events\/2016 Deals\/George P Johnson\/Barcelona", "https:\/\/XXXXX.XXXXXX.XXX\/index.php\/apps\/fil
  es\/?dir=\/XX+XXX\/XXXX\/2016+XXX\/XXXX+P+XXXX", "files", 454756]:
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1267692' for key 'PRIMARY'



  [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1267692' for key 'PRIMARY'



  [PDOException]
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1267692' for key 'PRIMARY'


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

bash-3.2#

So how to fix it ?

1 Like

I have the same problem here with Nextcloud 11.0.2. Trying to migrate from PostgreSQL to MySQL and the oc_filecache table fails to migrate because of:

[Doctrine\DBAL\Driver\PDOException]                                                               
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '444377' for key 'PRIMARY'  
                                                                                                                                  
  [PDOException]                                                                                    
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '444377' for key 'PRIMARY'