nextcloud / polls

🗳️ Polls app for Nextcloud
https://apps.nextcloud.com/apps/polls
GNU Affero General Public License v3.0
255 stars 73 forks source link

"occ db:convert-type" fails when polls are enabled #1420

Closed rnwgnr closed 3 years ago

rnwgnr commented 3 years ago

What is going wrong?

I want to use occ db:convert-type to migrate from SQLite to MySQL. The conversion fails on migrating the entries on "oc_polls_comments" due to a foreign key constraint failure.

To Reproduce Steps to reproduce the behavior:

  1. Setup a Nextcloud with SQlite
  2. Install "Polls" app
  3. Create a poll with atleast one comment
  4. Start a database migration with occ db:convert-type mysql <...> <...> <...>
  5. Migration fails due to foreign key constraints because the "oc_polls_comments" is to be migrated before the parent "oc_polls_polls" are.

Expected behavior Database migration using occ db:convert-type works successfully with the Polls app installed.

Screenshots

In AbstractMySQLDriver.php line 49:

  An exception occurred while executing 'INSERT INTO `oc_polls_comments` (`id`, `poll_id`, `user_id`, `dt`, `comment`, `timestamp`) VALUES(?, ?, ?, ?, ?, ?)' with params [...]:                                                                                          

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`nextcloud`.`oc_polls_comments`, CONSTRAINT `FK_8843EB9B3C947C0F` FOREIGN KEY (`poll_id  
  `) REFERENCES `oc_polls_polls` (`id`) ON DELETE CASCADE)                                                                                                                                                        

In PDOStatement.php line 129:

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`nextcloud`.`oc_polls_comments`, CONSTRAINT `FK_8843EB9B3C947C0F` FOREIGN KEY (`poll_id  
  `) REFERENCES `oc_polls_polls` (`id`) ON DELETE CASCADE)                                                                                                                                                        

In PDOStatement.php line 127:

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`d0356cab`.`oc_polls_comments`, CONSTRAINT `FK_8843EB9B3C947C0F` FOREIGN KEY (`poll_id  
  `) REFERENCES `oc_polls_polls` (`id`) ON DELETE CASCADE)                                                                                                                                                     

Information about your polls installation

Polls version? 1.7.5

Fresh installation or update from a prior version (from which one)? Update

How did you install this version?(Appstore or describe installation) AppStore

Information about your Instance of Nextcloud

Nextcloud version: 20.0.7

Nextcloud configuration:

If you have access to your command line run e.g.:
sudo -u www-data php occ config:list system
from within your Nextcloud installation folder

or

Insert your config.php content here
Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …)

Server configuration

Database: SQLite and MySQL 5.7

PHP version: 7.4

Are you using an external user-backend, if yes which one: No

dartcafe commented 3 years ago

That seems to be an issue for the server repo. IMHO occ db:convert-type should respect the existing constraints and migrate the correct way. Nothin, what we can do in the polls app, besides removing the constraints.

github-actions[bot] commented 3 years ago

This issue is marked as stale, because it had no activity in the last 30 days. It will be closed in 5 days.

github-actions[bot] commented 4 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.