mirror of
https://github.com/photoprism/photoprism.git
synced 2026-03-02 22:57:18 -05:00
MySQL 8: SQL Error on Database Migration, IF EXISTS not supported #1229
Labels
No labels
ai
android
api
auth
awesome
bug
bug
ci
cli
config
database
declined
deprecated
docker
docs 📚
documents
duplicate
easy
enhancement
enhancement
enhancement
epic
faces
feedback wanted
frontend
hacktoberfest
help wanted
idea
in-progress
incomplete
index
invalid
ios
labels
live
live
low-priority
macos
member-feature
metadata
mobile
nas
needs-analysis
no-coding-required
no-coding-required
observability
performance
places
please-test
plus-feature
priority
pro-feature
question
raspberry-pi
raw
released
released
released
research
resolved
security
sharing
tested
tests
third-party-issue
thumbnails
upgrade
upstream-issue
ux
vector
video
waiting
won't fix
won't fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/photoprism#1229
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hulmgulm on GitHub (Nov 28, 2021).
Originally assigned to: @lastzero on GitHub.
Updating from photoprism/photoprism 212018 docker image to 211127, the database migration fails with the following errors:
time="2021-11-28T05:10:21Z" level=error msg="migration 20211121-094727 failed: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS uix_places_place_label ON
places' at line 1 [3.510832ms]"time="2021-11-28T05:10:21Z" level=error msg="migration 20211124-120008 failed: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS idx_places_place_label ON
places' at line 1 [2.024121ms]"Database: MySQL 8.0.27
@lastzero commented on GitHub (Nov 28, 2021):
Oh wow, MySQL supports
IF EXISTSfor about everything - but not for indexes? Even SQLite supports it.Related to:
See also https://stackoverflow.com/questions/2480148/how-can-i-employ-if-exists-for-creating-or-dropping-an-index-in-mysql
As a workaround, you can manually run these statements without
IF EXISTSor otherwise drop the index on the label column of the places table:https://github.com/photoprism/photoprism/tree/develop/internal/migrate/mysql
Not happy we need to spend time writing complicated special migrations for MySQL 8. Indexes were created by the ORM in earlier versions, so we don't know 100% what the actual name is.
@lastzero commented on GitHub (Nov 28, 2021):
Would it be an option to use MariaDB 10.6 instead? Any features only MySQL 8 has?
@lastzero commented on GitHub (Nov 28, 2021):
Guess we could also ignore errors in the migration package if it's a drop statements, however that's dangerous as there can be other errors like invalid SQL too.
@hulmgulm commented on GitHub (Nov 28, 2021):
Thank you for your help. Only one of these three indexes existed. As the only migration steps were index drops, I don't think this is critical. I was worried that other DB changes were missing and PhotoPrism might not work as intended.
I've chose MySQL 8 because I had it already running.
@lastzero commented on GitHub (Nov 28, 2021):
It's critical in that the column is NOT UNIQUE anymore. So you will get INSERT / UPDATE errors when updating places.
@lastzero commented on GitHub (Nov 28, 2021):
Should be "fixed" with this:
github.com/photoprism/photoprism@7e8974fd20@lastzero commented on GitHub (Nov 28, 2021):
Started a new Development Preview build for testing! Should be available within the next hour...
@lastzero commented on GitHub (Nov 28, 2021):
Updated the System Requirements as we currently don't have time to run all tests on MySQL 8 before every release:
https://docs.photoprism.org/getting-started/#databases
Let us know when you run into issues and we do our best to help.
@lastzero commented on GitHub (Nov 28, 2021):
New Development Preview has been uploaded to Docker Hub.
@lastzero commented on GitHub (Nov 28, 2021):
Released the fix. Hope it works for everyone.
@lastzero commented on GitHub (Nov 28, 2021):
Announcement: https://twitter.com/photoprism_app/status/1464983836836704263
@hulmgulm commented on GitHub (Nov 28, 2021):
I've switched from MySQL to MariaDB for PhotoPrism.
Thank you for your help and timely response.
@polhaghverdian commented on GitHub (May 28, 2022):
@lastzero I have this exactly same error with release photoprism:220527-jammy
@lastzero commented on GitHub (May 28, 2022):
With MySQL 8? It's not supported anymore, see docs.
@polhaghverdian commented on GitHub (May 28, 2022):
Aha, didn't know that. Sorry!
@lastzero commented on GitHub (May 28, 2022):
Requires too many resources to completely test every release and add workarounds for MySQL 8, especially since we noticed that only very few users are (still) using it and can't upgrade....