Bug 394291 - cannot upgrade mysql db from v7 to v9
Summary: cannot upgrade mysql db from v7 to v9
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Database-Mysql (show other bugs)
Version: 5.9.0
Platform: Other Linux
: NOR major
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-15 20:02 UTC by Kusi
Modified: 2018-08-18 03:14 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kusi 2018-05-15 20:02:27 UTC
When I run Digikam 5.9 the first time, the mysql db is upgraded to v9. The upgrade failed with the error message:

Error messages: "QMYSQL: Unable to execute query" "BLOB/TEXT column 'name' used in key specification without a key length" 1170 2 
Bound values:  ()
digikam.dbengine: Error while executing DBAction [ "UpdateSchemaFromV7ToV9" ] Statement [ "ALTER TABLE Images MODIFY COLUMN name LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;" ]
digikam.coredb: Core database: schema update to V 9 failed!

Deleting the guilty index solved the issue for me
ALTER TABLE Images DROP INDEX image_name_index;

Is that a problem in general or where does my index coming from? Do I need to recreate it manually?

PS: I still cannot convert to v9, but these are other issues, to be investigated
Comment 1 Maik Qualmann 2018-05-15 20:23:04 UTC
Your database is probably very old. I can not reproduce at what time the "name" column in the "Images" table was a BLOB/TEXT field. Log into the database with mysql and do this:

UPDATE Settings SET value=9 WHERE keyword='DBVersion';

Create a new digiKam database. Then start digiKam and use the migration tool to export the old current database to the new.

Maik
Comment 2 Kusi 2018-05-15 20:39:25 UTC
my db is over 12 years old I guess. Looking at the mysql dump, there's indeed alot of garbage (many unneeded constraints and indexes) compared to how a new db looks like. Digikam with db v9 is now running, but I'll probably do the migration to a new db anyways. 

Just one question: do the ids for the images change during migration? I've added another table (for another project) whos foreign key is images.id. Therefore I currently rely on Images.id not being changed
Comment 3 Maik Qualmann 2018-05-15 20:46:34 UTC
No, the image ids do not change. Presumably, many orphaned will no longer exist after the migration. The database will certainly be smaller, but nothing should be lost.

Maik
Comment 4 caulier.gilles 2018-08-17 21:30:21 UTC
Can you reproduce the dysfunction using digiKam 6.0.0 pre-release bundle
available here :

https://files.kde.org/digikam/
Comment 5 Kusi 2018-08-17 22:58:30 UTC
I solved the issue by export/import of the database. That is probably good enough also for other users with this issue. I'm closing this bugreport
Comment 6 Kusi 2018-08-17 22:59:11 UTC
workaround in comment #1 is good enough