[digikam] [Bug 366445] New: MySQL Schema upgrade from V7 to V8 failes

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] New: MySQL Schema upgrade from V7 to V8 failes

bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

            Bug ID: 366445
           Summary: MySQL Schema upgrade from V7 to V8 failes
           Product: digikam
           Version: 5.1.0
          Platform: Compiled Sources
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: Database-Mysql
          Assignee: [hidden email]
          Reporter: [hidden email]

Created attachment 100460
  --> https://bugs.kde.org/attachment.cgi?id=100460&action=edit
Modified dbconfig.xml

After compiling and installing 5.1.0, running it throws up an error, "Failed to
update the database schema from version 7 to version 8."

I have been able to make this work with some changes to dbconfig.xml and also
some manual tweaking to the database. The issues with dbconfig.xml are: you
can't use (for example) "DROP KEY albumRoot" to delete a foreign key
constraint, you have to use "DROP FOREIGN KEY Albums_AlbumRoots" for example;
some tables already have a foreign key but there is no DROP FOREIGN KEY (or
DROP KEY) statement; there is a typo in the code to update MIN(lft) and
MAX(rgt) values for the Tags table; and finally for MySQL prior to 5.6 (I've
got 5.5) you need to do the DROP FOREIGN KEY in a separate statement to adding
the new foreign key constraint.

In my case, the database was a bit of a mess with (for example)
ImageInformation rows for Images which no longer exist, so the foreign key
constraint is violated. I fixed this by hand, but it would be possible to make
a helper script which could find these violations and give the user the option
to fix them by  deleting the offending entries.

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

Ian Dall <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|MySQL Schema upgrade from   |MySQL Schema upgrade from
                   |V7 to V8 failes             |V7 to V8 fails

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

[hidden email] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email],
                   |                            |[hidden email]

--- Comment #1 from [hidden email] ---
Maik,

Could you please tell if it's reproducible for you?
With the same queries, I was able to make an update from v7 to v8, which works
fine now.

Swati

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #2 from Ian Dall <[hidden email]> ---
Yes, it is definitely reproducible. It might be MySQL version specific though.
I can see it is at least possible that later versions of MySQL would allow you
to use DROP KEY to drop a key and any constraints associated with it.

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #3 from [hidden email] ---
(In reply to Ian Dall from comment #2)
> Yes, it is definitely reproducible. It might be MySQL version specific
> though. I can see it is at least possible that later versions of MySQL would
> allow you to use DROP KEY to drop a key and any constraints associated with
> it.

I created a random test database with just 2 tables and foreign key constraint.
I tried "DROP KEY" and it didn't work for me. I use MariaDB 10.1

Strange, that it didn't cause any error while switching from v7 to v8....

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #4 from [hidden email] ---
Created attachment 100463
  --> https://bugs.kde.org/attachment.cgi?id=100463&action=edit
Patch for testing

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #5 from Maik Qualmann <[hidden email]> ---
Created attachment 100472
  --> https://bugs.kde.org/attachment.cgi?id=100472&action=edit
schema2.patch

I have created a new patch from the dbconfig.xml. This patch works here. Swati,
look at the end of the patch where it failed with  KEY u_tag. I can the KEY
u_tag throughout DB schema not find?

Maik

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

Maik Qualmann <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #100463|0                           |1
        is obsolete|                            |

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #6 from [hidden email] ---
Created attachment 100480
  --> https://bugs.kde.org/attachment.cgi?id=100480&action=edit
To move from V7 to V8

Maik,

I tested your last patch. It works fine for me too.  I've successfully moved
from version 7 to 8.

Won't the UNIQUE constraint be required for existing DB, upgrading version?

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

[hidden email] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|MySQL Schema upgrade from   |MySQL Schema upgrade from
                   |V7 to V8 fails              |V7 to V8 fails [patch]
                 CC|                            |[hidden email]

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #7 from [hidden email] ---
Swati, Maik,

5.1.0 will be released normally tomorrow evening. Any chance to see this patch
applied to git/master before the release ?

Gilles

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #8 from [hidden email] ---
Since this patch works, I think this could be applied.  
Still I would like Maik to confirm the same.

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #9 from Maik Qualmann <[hidden email]> ---
I just check the patch again step by step and will then apply it.

Maik

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

Maik Qualmann <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
   Version Fixed In|                            |5.1.0
         Resolution|---                         |FIXED
      Latest Commit|                            |http://commits.kde.org/digi
                   |                            |kam/882411060361ff183b770d6
                   |                            |3db1ded8c55fe0643

--- Comment #10 from Maik Qualmann <[hidden email]> ---
Git commit 882411060361ff183b770d63db1ded8c55fe0643 by Maik Qualmann.
Committed on 06/08/2016 at 19:47.
Pushed by mqualmann into branch 'master'.

add changes from Ian Dall to fix MySQL schema upgrade from V7 to V8
FIXED-IN: 5.1.0

M  +2    -1    NEWS
M  +44   -10   data/database/dbconfig.xml.cmake.in

http://commits.kde.org/digikam/882411060361ff183b770d63db1ded8c55fe0643

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

[hidden email] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|5.1.0                       |5.0.0

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #11 from Ian Dall <[hidden email]> ---
I think I can add some insight into why this worked for some and not others. I
noticed in the MySQL documentation that ROLLBACK does not roll back ALTER
commands!

V7 did not have any foreign key constraints. In my case, the upgrade failed,
probably due to constraint violations (eg ImageInformation rows referring to
Image rows which had been deleted), but the ALTER commands to create the
foreign constraint constraints up to that point worked, and were not rolled
back. The next time I tried to upgrade, the foreign key constraint already
existed, so DROP KEY didn't work and the the script failed early.

Someone else, without cruft in their V7 database, would have succeeded first
time.

I am unsure whether my patches work with a clean V7 database. I guess dropping
a constraint that doesn't exist may fail. I would test this, (I did back up my
V7 database before doing all this) but I would have to clean the cruft again,
which is a non-trivial process because I did it by hand.

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 366445] MySQL Schema upgrade from V7 to V8 fails [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=366445

--- Comment #12 from [hidden email] ---
Sounds like that could probably be an issue.

You could refer to comments in other Bugzilla entry
https://bugs.kde.org/show_bug.cgi?id=355831#c73 .Go through 2-3 attachments
that might help you to detect invalid data before updating.

--
You are receiving this mail because:
You are the assignee for the bug.