cakephp / phinx

PHP Database Migrations for Everyone
https://phinx.org
MIT License
4.45k stars 895 forks source link

Fix tests for MySQL 8.4 #2281

Closed ajibarra closed 3 months ago

ajibarra commented 3 months ago

Fixes #2277

The issue is caused by a new behavior in Mysql 8.4 that throws an error when you create a FK in table A to table B if Table B does not have a unique constraint.

SQLSTATE[HY000]: General error: 6125 Failed to add the foreign key constraint. Missing unique key for constraint 'FOREIGN_KEY' in the referenced table 'TABLE' 

There is a workaround setting variable RESTRICT_FK_ON_NON_STANDARD_KEY to OFF (ON by default) but in the case of the unit tests it would be enough to create keys as unique.

The report: https://bugs.mysql.com/bug.php?id=114838

@MasterOdin please let me know your thoughts

MasterOdin commented 3 months ago

Thanks for figuring this out, and happy that it was just a test change that was required!