Bug 388533 - UpdateSchemaFromV7ToV9 fails
Summary: UpdateSchemaFromV7ToV9 fails
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Schema (show other bugs)
Version: 5.8.0
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-04 17:11 UTC by Jyrki Soini
Modified: 2019-03-20 18:28 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jyrki Soini 2018-01-04 17:11:08 UTC
~> digikam-5.8.0-20180104T050630-x86-64.appimage 
-- digiKam AppImage Bundle
-- Use 'help' as CLI argument to know all available options
digikam.widgets: Breeze icons ressource file found
digikam.general: AlbumWatch use QFileSystemWatcher
digikam.general: Database Parameters:
   Type:                     "QMYSQL"
   DB Core Name:             "digikam"
   DB Thumbs Name:           "digikam"
   DB Face Name:             "digikam"
   Connect Options:          "UNIX_SOCKET=/run/mysql/mysql.sock"
   Host Name:                "localhost"
   Host port:                3306
   Internal Server:          false
   Internal Server Path:     ""
   Internal Server Serv Cmd: ""
   Internal Server Init Cmd: ""
   Username:                 "digikam"
   Password:                 "XXXXXXXXXXXXXXXXXXXX"

digikam.dbengine: Loading SQL code from config file "/tmp/.mount_digikadmlBjZ/usr/share/digikam/database/dbconfig.xml"
digikam.dbengine: Checking XML version ID => expected:  3  found:  3
digikam.coredb: Core database: running schema update
digikam.coredb: Core database: have a structure version  8
digikam.coredb: Core database: makeUpdates  8  to  9
digikam.dbengine: Failure executing query:
 "" 
Error messages: "QMYSQL: Unable to execute query" "Duplicate entry '1-/haat' for key 'albumRoot'" 1062 2 
Bound values:  ()
digikam.dbengine: Error while executing DBAction [ "UpdateSchemaFromV7ToV9" ] Statement [ "ALTER TABLE Albums\n                                        ADD CONSTRAINT Albums_AlbumRoots FOREIGN KEY (albumRoot) REFERENCES AlbumRoots (id) ON DELETE CASCADE ON UPDATE CASCADE,\n                                        ADD UNIQUE (albumRoot, relativePath(255)),\n                                        ENGINE InnoDB;" ]
digikam.coredb: Core database: schema update to V 9 failed!
digikam.coredb: Core database: cannot process schema initialization
KMemoryInfo: Platform identified :  "LINUX"
KMemoryInfo: TotalRam:  16765001728
digikam.general: Allowing a cache size of 200 MB
QThreadStorage: Thread 0x7f4460d07680 exited after QThreadStorage 11 destroyed
Comment 1 Maik Qualmann 2018-01-04 17:29:05 UTC
*** This bug has been marked as a duplicate of bug 388501 ***
Comment 2 Maik Qualmann 2018-01-04 17:32:22 UTC
Ok, a little further. So we can not add CONSTRAINT if duplicate data already exists. I see no other solution than to search for duplicate data and delete it beforehand.

Maik
Comment 3 Jyrki Soini 2018-01-06 18:50:34 UTC
UpdateSchemaFromV7ToV9 still fails in digikam-5.8.0-20180106T073314-x86-64.appimage

~> digikam-5.8.0-20180106T073314-x86-64.appimage 
-- digiKam AppImage Bundle
-- Use 'help' as CLI argument to know all available options
digikam.widgets: Breeze icons ressource file found
digikam.general: AlbumWatch use QFileSystemWatcher
digikam.general: Database Parameters:
   Type:                     "QMYSQL"
   DB Core Name:             "digikam"
   DB Thumbs Name:           "digikam"
   DB Face Name:             "digikam"
   Connect Options:          "UNIX_SOCKET=/run/mysql/mysql.sock"
   Host Name:                "localhost"
   Host port:                3306
   Internal Server:          false
   Internal Server Path:     ""
   Internal Server Serv Cmd: ""
   Internal Server Init Cmd: ""
   Username:                 "digikam"
   Password:                 "XXXXXXXXXXXXXXXXXXXX"

digikam.dbengine: Loading SQL code from config file "/tmp/.mount_digikavZSpSc/usr/share/digikam/database/dbconfig.xml"
digikam.dbengine: Checking XML version ID => expected:  3  found:  3
digikam.coredb: Core database: running schema update
digikam.coredb: Core database: have a structure version  8
digikam.coredb: Core database: makeUpdates  8  to  9
digikam.dbengine: Failure executing query:
 "" 
Error messages: "QMYSQL: Unable to execute query" "Cannot add or update a child row: a foreign key constraint fails (`digikam`.`#sql-83e_13`, CONSTRAINT `Images_Albums` FOREIGN KEY (`album`) REFERENCES `Albums` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)" 1452 2 
Bound values:  ()
digikam.dbengine: Error while executing DBAction [ "UpdateSchemaFromV7ToV9" ] Statement [ "ALTER IGNORE TABLE Images\n                                        ADD CONSTRAINT Images_Albums FOREIGN KEY (album) REFERENCES Albums (id) ON DELETE CASCADE ON UPDATE CASCADE,\n                                        ADD UNIQUE (album, name(255)),\n                                        ENGINE InnoDB;" ]
digikam.coredb: Core database: schema update to V 9 failed!
digikam.coredb: Core database: cannot process schema initialization
KMemoryInfo: Platform identified :  "LINUX"
KMemoryInfo: TotalRam:  16765001728
digikam.general: Allowing a cache size of 200 MB
QThreadStorage: Thread 0x7f531dff3c80 exited after QThreadStorage 11 destroyed
Comment 4 Maik Qualmann 2018-01-06 19:35:40 UTC
I have recreated this error (wrong foreign key constraint), but with MarioDB there are no problems. We set FOREIGN_KEY_CHECKS=0, that should work. I will see if I can find MySQL packages for my distribution.

Maik
Comment 5 Jyrki Soini 2018-01-07 18:29:09 UTC
The errors I reported are against MariaDB 10.2.11.
Comment 6 Jyrki Soini 2018-01-07 18:41:47 UTC
~> digikam-5.8.0-20180107T063018-x86-64.appimage 
-- digiKam AppImage Bundle
-- Use 'help' as CLI argument to know all available options
digikam.widgets: Breeze icons ressource file found
digikam.general: AlbumWatch use QFileSystemWatcher
digikam.general: Database Parameters:
   Type:                     "QMYSQL"
   DB Core Name:             "digikam"
   DB Thumbs Name:           "digikam"
   DB Face Name:             "digikam"
   Connect Options:          "UNIX_SOCKET=/run/mysql/mysql.sock"
   Host Name:                "localhost"
   Host port:                3306
   Internal Server:          false
   Internal Server Path:     ""
   Internal Server Serv Cmd: ""
   Internal Server Init Cmd: ""
   Username:                 "digikam"
   Password:                 "XXXXXXXXXXXXXXXXXXXX"

digikam.dbengine: Loading SQL code from config file "/tmp/.mount_digikaz3rtS4/usr/share/digikam/database/dbconfig.xml"
digikam.dbengine: Checking XML version ID => expected:  3  found:  3
digikam.coredb: Core database: running schema update
digikam.coredb: Core database: have a structure version  8
digikam.coredb: Core database: makeUpdates  8  to  9
digikam.dbengine: Failure executing query:
 "" 
Error messages: "QMYSQL: Unable to execute query" "Cannot add or update a child row: a foreign key constraint fails (`digikam`.`#sql-7609_b`, CONSTRAINT `Images_Albums` FOREIGN KEY (`album`) REFERENCES `Albums` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)" 1452 2 
Bound values:  ()
digikam.dbengine: Error while executing DBAction [ "UpdateSchemaFromV7ToV9" ] Statement [ "ALTER IGNORE TABLE Images\n                                        ADD CONSTRAINT Images_Albums FOREIGN KEY (album) REFERENCES Albums (id) ON DELETE CASCADE ON UPDATE CASCADE,\n                                        ADD UNIQUE (album, name(255)),\n                                        ENGINE InnoDB;" ]
digikam.coredb: Core database: schema update to V 9 failed!
digikam.coredb: Core database: cannot process schema initialization
KMemoryInfo: Platform identified :  "LINUX"
KMemoryInfo: TotalRam:  16765001728
digikam.general: Allowing a cache size of 200 MB
QThreadStorage: Thread 0x7f9e2a0f1c80 exited after QThreadStorage 11 destroyed
Comment 7 caulier.gilles 2018-08-28 14:07:09 UTC
Problem still reproducible with AppImage bundle 6.0.0-beta1 available here :

https://files.kde.org/digikam/

Gilles Caulier
Comment 8 caulier.gilles 2019-03-20 18:28:03 UTC
Not reproducible with last 6.1.0 pre-release AppImage bundle :

https://files.kde.org/digikam/

Gilles Caulier