[SOLVED] ownCloud to Nextcloud migration - oc_accounts foreign key constraint fails

Hi,

Today I attempted to migrate from ownCloud 10.0.10 to Nextcloud 12.0.13 following the manual process instructions here:

Unfortunately I received the following error.

# su apache -s /bin/bash -c '/opt/rh/rh-php71/root/bin/php /domains/example.com/occ upgrade'
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Set log level to debug
Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: An exception occurred while executing 'DROP TABLE oc_accounts':
SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or update a parent row: a foreign key constraint fails
Update failed
Maintenance mode is kept active
Reset log level

I was hoping perhaps someone might be able to point me in the right direction on how to resolve this.

Let me know if any further information is required.

Database: MariaDB 5.5.60

Thanks,

Paul.

I found the foreign key constraint. Is it safe to drop this constraint?

MariaDB [(none)]> SELECT TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
    -> FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
    -> WHERE REFERENCED_TABLE_SCHEMA = 'owncloud' AND REFERENCED_TABLE_NAME = 'oc_accounts';
+---------------------+------------------+---------------------+-----------------------+------------------------+
| TABLE_NAME          | COLUMN_NAME      | CONSTRAINT_NAME     | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+---------------------+------------------+---------------------+-----------------------+------------------------+
| oc_persistent_locks | owner_account_id | FK_F0C3D55BC901C6FF | oc_accounts           | id                     |
+---------------------+------------------+---------------------+-----------------------+------------------------+
1 row in set (0.47 sec)

This is not the answer of your question but I would not try to migrate to an unsupported
Nextcloud version. You should better try to mirate directly to Nextcloud 14.x/15.x, because
these are supported versions.

That is not the recommended migration path. Quoting from the article: ‘You can update from ownCloud 10.0.10 and older to Nextcloud 12.0.12 after which you can use our update to move to a newer Nextcloud release’.

Reading that back now perhaps I should try 12.0.12 instead of 12.0.13?

All I can say is, that this query returns an Empty set on my two nextcloud instances. So it looks like it is not needed by nextcloud. Maybe, create a database dump first, drop this constraint and then have a look if the migration runs through successfully

I would migrate to 12.0.13

This is not possible and not an allowed migration path. Migrations from ownCloud need to go through Nextcloud 12 and then have to be upgraded to supported versions (https://docs.nextcloud.com/server/15/admin_manual/maintenance/migrating_owncloud.html).

I managed to successfully complete the migration.

The oc_persistent_locks had two constraints the one above on oc_accounts and another on oc_filecache. I had to drop both of them for the migration script to complete successfully.

Over the next few weekends I will update Nextcloud to a supported version.

Thank you for the assist.

3 Likes

Thanks for this. I had the same issue. Solved deleting the same two constraints.