php - A foreign key constraint fails on production but not on localhost

one text

Solution:

Different versions of MySQL, at a guess. In both of your constraints you reference the table name with a capital letter.

CONSTRAINT `posts_author_id_foreign` FOREIGN KEY (`author_id`) REFERENCES `Authors` (`id`) ON DELETE CASCADE,
CONSTRAINT `posts_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `Categories` (`id`) ON DELETE CASCADE

MySQL 8.0 can deal with that, MySQL5.7 can not (going by tests on my own localhost and production setups).

Source