Upgrading 8.5.2 to 8.5.6 fails with foreign key error

PHP 7.4.33
Concrete5 8.5.2 → 8.5.6

This site was running on an ancient version of Concrete5 (8.2.1). I have managed to update to version 8.5.2. I now run into this issue: Upgrading Concrete from 8.5 to 9.x :: Concrete CMS
And the linked github page: Migration error 8.5.2 -> 8.5.4 · Issue #8981 · concretecms/concretecms · GitHub
Does not resolve the issue.

When I execute ./concrete/bin/concrete5 c5:update && ./concrete/bin/concrete5 c5:package-update --all && ./concrete/bin/concrete5 c5:entities:refresh, that appears to be working as expected. I then follow that with ./concrete/bin/concrete5 c5:database:charset:set utf8mb4, but that does not work as it keeps throwing the same errors that the Foreign Key can’t be updated:

converting table “atExpressSettings”: An exception occurred while executing ‘ALTER TABLE atExpressSettings CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci’:
SQLSTATE[HY000]: General error: 1832 Cannot change column ‘exEntityID’: used in a foreign key constraint ‘FK_E8F67F0FCE2D7284’

I have been working on this issue for days now and I’m unable to get passed it to move the side up in the versioning scheme.

What else might I give a try?

If you have access to phpMyAdmin or Adminer you could run the query manually like this

SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE atExpressSettings CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
SET FOREIGN_KEY_CHECKS=1;

If there are more errors like this an you have access to the command line you can run

concrete/bin/concrete5 orm:schema-tool:update --dump-sql

and that will give you all the queries to put between the “SET FORIEGN_KEY_CHECKS” lines there to complete the upgrade.

When I tried to execute the statements in PhpMyAdmin it throws an error as well.

#1832 - Cannot change column 'exEntityID': used in a foreign key constraint 'FK_E8F67F0FCE2D7284'

The SQL dump provides a huge list of alter statements. I executed those, but nothing was updated according to Mysql.

Did you include the first and last lines of the sample I shared? The query seems to be still checking Foreign Key Constraints.

Yes. I wrapped it in the Foreign Key Checks.

Well that’s odd, I’ve never had that not work.

Yeah, that’s why I’m stumped and stuck.

Do you have a lot of custom express entities set up in this site? Just wondering if something might’ve gotten deleted without cleaning itself up. Sometimes that can happen with a user getting deleted, so maybe if there’s an Express entity associated with a user? But those are just wild guesses.