Migration from Owncloud to Nextcloud fails

Hi,

I have to migrate a Owncloud 10.0.7.2 instance to Nextcloud, I will get a database dump from my provider on wednesday. To test the migration path I installed Owncloud (version 10.0.10.4) in VirtualBox and dumped the database. I started a docker container (from Docker Hub, Version “nextcloud:12.0.13-apache”) on my new Server (Ubuntu 18.04 LTS).
I restored the database and user data as it is described on https://hub.docker.com/_/nextcloud/ in section “Migrating an existing installation”. Unfortunately the upgrade fails with a database error. I start it with su -p www-data -s /bin/sh -c "php /var/www/html/occ upgrade -vvv" and tested it serveral times.
Here is the output:

Set log level to debug                                                
Repair step: Repair MySQL collation                                   
Repair info: Change row format for oc_migrations ...                  
Repair info: Change collation for oc_migrations ...                   
Repair step: Repair SQLite autoincrement                              
Repair step: Copy data from accounts table when migrating from ownClou
                                                                      
Repair step: Drop account terms table when migrating from ownCloud    
Updating database schema                                              
Updated database                                                      
Updating <files_videoplayer> ...                                      
Updated <files_videoplayer> to 1.1.0                                  
Updating <firstrunwizard> ...                                         
Updated <firstrunwizard> to 2.1                                       
Updating <provisioning_api> ...                                       
Updated <provisioning_api> to 1.2.0                                   
Updating <updatenotification> ...                                     
Updated <updatenotification> to 1.2.0                                 
Updating <federation> ...                                             
Updated <federation> to 1.2.0                                         
Updating <user_ldap> ...                                              
Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'ALTER TABLE oc_ldap_group_mapping DROP PRIMARY KEY':                                  
                                                                                                
SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP INDEX `PRIMARY`; check that i
t exists                                                                                        
2018-12-17T13:31:35+00:00 Update failed                                                         
2018-12-17T13:31:35+00:00 Maintenance mode is kept active                                       
2018-12-17T13:31:35+00:00 Reset log level  

I looked for primary keys on the mentioned table oc_ldap_group_mapping with the mysql command describe oc_ldap_group_mapping and got the following output:
-> before trying to update with occ:


+----------------+--------------+------+-----+---------+-------+
| Field          | Type         | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| owncloud_name  | varchar(255) | NO   | PRI | NULL    |       |
| ldap_dn        | varchar(255) | NO   | UNI | NULL    |       |
| directory_uuid | varchar(255) | NO   |     | NULL    |       |
+----------------+--------------+------+-----+---------+-------+

-> and after trying to update with occ:

+----------------+--------------+------+-----+---------+-------+
| Field          | Type         | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+-------+
| owncloud_name  | varchar(255) | NO   |     | NULL    |       |
| ldap_dn        | varchar(255) | NO   | PRI | NULL    |       |
| directory_uuid | varchar(255) | NO   |     | NULL    |       |
+----------------+--------------+------+-----+---------+-------+

Can you give me an advice what I’m doing wrong?
Greetings, Patrick

Hi guys
I could solve the issue. After the upgrade had failed, I dropped the index of the attribute ldap_dn by ALTER TABLE oc_ldap_group_mapping DROP INDEXindex_name; (sorry currently I do not know what the index_name was). As you could assume from the last listing above, there didn’t exist a primary key for ldap_dn, it’s a unique key/index. I figured it out from the output of show keys from oc_ldap_group_mapping;.
After dropping the index, I started the upgrade process again by php occ upgrade and it finished successfully.
Kind regards, Patrick