# Database migration error FOREIGN KEY constraint

**URL:** https://forum.mautic.org/t/database-migration-error-foreign-key-constraint/18413
**Category:** Mautic 3 - Install/Upgrade Support
**Created:** [March 3, 2021, 10:49am UTC](https://forum.mautic.org/t/database-migration-error-foreign-key-constraint/18413 "2021-03-03T10:49:39Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![aerendir](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/aerendir/32/1050_2.png) [@aerendir](https://forum.mautic.org/u/aerendir)
#### Post date: [February 18, 2022, 3:59pm UTC](https://forum.mautic.org/t/database-migration-error-foreign-key-constraint/18413/4 "2022-02-18T15:59:51Z")

</div>

I’ve just replied here giving a bit more context about the issue: it is the same issue

> [@Error Updating from Mautic 3.0 --\>3.01](https://forum.mautic.org/t/error-updating-from-mautic-3-0-3-01/15038/11):
>
> Dropping the foreign key doesn’t work. Once dropped, running a bin/console doctrine:schema:update --force tries to recreate the foreign key, but the query results in an error: An exception occurred while executing ‘ALTER TABLE \*\_oauth2\_accesstokens ADD CONSTRAINT FK\_E6019FAD19EB6921 FOREIGN KEY (client\_id) REFERENCES \*\_oauth2\_clients (id) ON DELETE CASCADE’: SQLSTATE[HY000]: General error: 3780 Referencing column ‘client\_id’ and referenced column ‘id’ in foreign key constraint ‘FK\_E6019FAD19…

---

_[View the full topic](https://forum.mautic.org/t/database-migration-error-foreign-key-constraint/18413)._
