Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations fail in MySQL 8.4 #1460

Open
trckster opened this issue May 16, 2024 · 1 comment
Open

Migrations fail in MySQL 8.4 #1460

trckster opened this issue May 16, 2024 · 1 comment
Labels

Comments

@trckster
Copy link

🐞 Bug Report

Required Information

? !
Operating system Docker: php:8.3-cli
PHP Telegram Bot version 0.82
PHP version 8.3
MySQL version 8.4
Update Method - (don't even start bot)
Self-signed certificate -
RAW update (if available) -

Summary

Migrations aren't working for MySQL 8.4. Error occurs during creation telegram_update table:

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 6125 Failed to add the foreign key constraint. Missing unique key for constraint 'telegram_update_ibfk_11' in the referenced table 'poll_answer' in /app/vendor/illuminate/database/Connection.php:587

Everything works well if I use MySQL version 8.3, so I'm supposing that database developers changed something and now migrations stopped working.

Current behaviour

Migrations crashing.
image

How to reproduce

Apply migration in MySQL 8.4.

Expected behaviour

Migrations finish successfully.

@trckster trckster added the bug label May 16, 2024
@dva-re
Copy link
Contributor

dva-re commented Sep 11, 2024

Temporary workarround is

SET GLOBAL restrict_fk_on_non_standard_key = 'OFF'

This is because

Nonstandard foreign keys. The use of non-unique or partial keys as foreign keys is nonstandard, and is deprecated in MySQL. Beginning with MySQL 8.4.0, you must explicitly enable such keys by setting restrict_fk_on_non_standard_key to OFF, or by starting the server with --skip-restrict-fk-on-non-standard-key.

restrict_fk_on_non_standard_key is ON by default, which means that trying to use a nonstandard key as a foreign key in a CREATE TABLE or other SQL statement is rejected with ER_WARN_DEPRECATED_NON_STANDARD_KEY. Setting it to ON allows such statements to run, but they raise the same error as a warning.

from: https://dev.mysql.com/doc/refman/8.4/en/mysql-nutshell.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants