docker-library / mysql

Docker Official Image packaging for MySQL Community Server
https://dev.mysql.com/
GNU General Public License v2.0
2.46k stars 2.19k forks source link

MySQL 8.4: 6125 (HY000) at line 1197: Failed to add the foreign key constraint. Missing unique key for constraint #1052

Closed finpension-aless closed 4 months ago

finpension-aless commented 4 months ago

With the newest image available on DockerHub (mysql:8) we run into an issue when we run our migration scripts for our tests.

We get the error "ERROR 6125 (HY000) at line 1197: Failed to add the foreign key constraint. Missing unique key for constraint 'tbl_temp_transactions_currency_foreign' in the referenced table 'tbl_currencies'"

image

image

When using the docker image mysql:8.3 this error does not happen. We didn't change any MySQL configuration ourselves.

Adding an unique-key on 'to_currency' is not possible for us, since it's not a unique column. According to the MySQL documentation that shouldn't be an issue though since we use InnoDB which allows it. I also tried to add a simple index on 'to_currency' but it didn't help.

tianon commented 4 months ago

Weren't there quite a few breaking changes in MySQL 8.4? I don't know all the details (of the release or your situation), but that would be my best guess offhand.

(We merely package MySQL straight from upstream with very minimal configuration changes, so it's unlikely this is uniquely the fault of the Docker image, and more likely this would exhibit with a more traditional MySQL 8.4 installation as well.)

finpension-aless commented 4 months ago

Okay thanks for the feedback, I will bring it up there then :)