# Issue after 8.5.x update towards 9.x - Foreign key constraint is incorrectly formed

**URL:** <https://forums.concretecms.org/t/issue-after-8-5-x-update-towards-9-x-foreign-key-constraint-is-incorrectly-formed/7438>\
**Category:** Installation\
**Created:** [May 18, 2024, 12:38pm UTC](https://forums.concretecms.org/t/issue-after-8-5-x-update-towards-9-x-foreign-key-constraint-is-incorrectly-formed/7438 "2024-05-18T12:38:20Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![JohntheFish](https://forums.concretecms.org/user_avatar/forums.concretecms.org/johnthefish/32/3767_2.png) [@JohntheFish](https://forums.concretecms.org/u/JohntheFish)\
**Post date:** [May 18, 2024, 5:43pm UTC](https://forums.concretecms.org/t/issue-after-8-5-x-update-towards-9-x-foreign-key-constraint-is-incorrectly-formed/7438/2 "2024-05-18T17:43:55Z")

</div>

Its a chicken and egg problem with dependencies in the oAuth tables (you can get similar with express), usually when updating the character set.

If the rest of the update works from the CLI, and you are not using oAuth, you can delete the tables and import them from a fresh 9.x install. Or @jero posted a script to fix from MySQL.

> [@Error upgrading 8.5.16 to 9.2.8](https://forums.concretecms.org/t/error-upgrading-8-5-16-to-9-2-8/7315):
>
> I’m using the elemental theme. I’ve replaced /concrete with the same folder from 9.2.8. I visit the site and get the following error: An exception occurred while executing ‘ALTER TABLE OAuth2ClientScopes ADD CONSTRAINT FK\_497E26F3C7FD45E9 FOREIGN KEY (scopeIdentifier) REFERENCES OAuth2Scope (identifier)’: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint I’ve checked the collation on both tables and they match.

---

_[View the full topic](https://forums.concretecms.org/t/issue-after-8-5-x-update-towards-9-x-foreign-key-constraint-is-incorrectly-formed/7438)._
