# Error upgrading 8.5.16 to 9.2.8

**URL:** <https://forums.concretecms.org/t/error-upgrading-8-5-16-to-9-2-8/7315>\
**Category:** Developing with Concrete\
**Created:** [April 30, 2024, 3:57pm UTC](https://forums.concretecms.org/t/error-upgrading-8-5-16-to-9-2-8/7315 "2024-04-30T15:57:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonchilton](https://forums.concretecms.org/user_avatar/forums.concretecms.org/simonchilton/32/4205_2.png) [@simonchilton](https://forums.concretecms.org/u/simonchilton)\
**Post date:** [April 30, 2024, 3:57pm UTC](https://forums.concretecms.org/t/error-upgrading-8-5-16-to-9-2-8/7315/1 "2024-04-30T15:57:58Z")

</div>

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.

---

<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:** [April 30, 2024, 5:01pm UTC](https://forums.concretecms.org/t/error-upgrading-8-5-16-to-9-2-8/7315/2 "2024-04-30T17:01:19Z")

</div>

There is a chicken and egg issue with the oAuth tables when updating from 8 to 9. Dependencies between the tables prevent them from updating - even if empty. If you are not using oAuth at all, you can safely remove them and replace with similar from a fresh 9.2.x install.

---

<div class="post-metadata">

**Author:** ![simonchilton](https://forums.concretecms.org/user_avatar/forums.concretecms.org/simonchilton/32/4205_2.png) [@simonchilton](https://forums.concretecms.org/u/simonchilton)\
**Post date:** [May 2, 2024, 3:08pm UTC](https://forums.concretecms.org/t/error-upgrading-8-5-16-to-9-2-8/7315/3 "2024-05-02T15:08:47Z")

</div>

Cheers, John, worked great.

I deleted all tables containing oAuth and imported the same set of tables from a 9.2 database.

I then ran in to another error, a couple of tables related to messages were missing. Importing these from 9.2 sorted, and the upgrade ran smoothly.

Great tip, thanks again John!!

---

<div class="post-metadata">

**Author:** ![jero](https://forums.concretecms.org/user_avatar/forums.concretecms.org/jero/32/5306_2.png) [@jero](https://forums.concretecms.org/u/jero)\
**Post date:** [May 5, 2024, 11:32pm UTC](https://forums.concretecms.org/t/error-upgrading-8-5-16-to-9-2-8/7315/4 "2024-05-05T23:32:25Z")

</div>

I’ve run into this same issue, but only on databases that were created on a host that doesn’t support the utf8\_mb4 character set, and were later transferred to a host that does.

My preferred solution is to convert the tables:

```auto
SET FOREIGN_KEY_CHECKS=0;

ALTER TABLE `OAuth2AccessToken` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `OAuth2AccessToken` CHANGE `identifier` `identifier` char(36) NOT NULL COMMENT '(DC2Type:guid)';

ALTER TABLE `OAuth2AccessToken` CHANGE `client` `client` char(36) DEFAULT NULL COMMENT '(DC2Type:guid)';

ALTER TABLE `OAuth2AccessToken` CHANGE `scopes` `scopes` longtext NOT NULL COMMENT '(DC2Type:json_array)';

ALTER TABLE `OAuth2AuthCode` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `OAuth2AuthCode` CHANGE `identifier` `identifier` char(36) NOT NULL COMMENT '(DC2Type:guid)';

ALTER TABLE `OAuth2AuthCode` CHANGE `client` `client` char(36) DEFAULT NULL COMMENT '(DC2Type:guid)';

ALTER TABLE `OAuth2AuthCode` CHANGE `scopes` `scopes` longtext NOT NULL COMMENT '(DC2Type:json_array)';

ALTER TABLE `OAuth2Client` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `OAuth2Client` CHANGE `identifier` `identifier` char(36) NOT NULL COMMENT '(DC2Type:guid)';

ALTER TABLE `OAuth2Client` CHANGE `name` `name` varchar(255) NOT NULL;

ALTER TABLE `OAuth2Client` CHANGE `redirectUri` `redirectUri` varchar(255) NOT NULL;

ALTER TABLE `OAuth2Client` CHANGE `clientKey` `clientKey` varchar(255) NOT NULL;

ALTER TABLE `OAuth2Client` CHANGE `clientSecret` `clientSecret` varchar(255) NOT NULL;

ALTER TABLE `OAuth2RefreshToken` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `OAuth2RefreshToken` CHANGE `identifier` `identifier` char(36) NOT NULL COMMENT '(DC2Type:guid)';

ALTER TABLE `OAuth2RefreshToken` CHANGE `accessToken` `accessToken` char(36) DEFAULT NULL COMMENT '(DC2Type:guid)';

ALTER TABLE `OAuth2Scope` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `OAuth2Scope` CHANGE `identifier` `identifier` varchar(255) NOT NULL;

ALTER TABLE `OAuth2Scope` CHANGE `description` `description` varchar(255) NOT NULL;
```
