# SQL Error upgrading to Mautic 4

**URL:** <https://forum.mautic.org/t/sql-error-upgrading-to-mautic-4/21067>\
**Category:** General Discussion\
**Created:** [September 29, 2021, 7:28pm UTC](https://forum.mautic.org/t/sql-error-upgrading-to-mautic-4/21067 "2021-09-29T19:28:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cStuartHardwick](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/cstuarthardwick/32/5695_2.png) [@cStuartHardwick](https://forum.mautic.org/u/cStuartHardwick)\
**Post date:** [September 29, 2021, 7:28pm UTC](https://forum.mautic.org/t/sql-error-upgrading-to-mautic-4/21067/1 "2021-09-29T19:28:25Z")

</div>

I tried the Mautic 4.0 upgrade today–from the terminal, not the “upgrade now” button because I’ve well and truly learned that lesson.

Went okay until I ran “php bin/console mautic:update:apply --finish” then I got the generic “An error occurred while updating the database. Check log for more details.” and the log reported “Can’t DROP FOREIGN KEY `FK_A92BEF2937FDBD6D`; … at /home/cstukfps/email/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 128 while running console command …”

This is similar to what happened on my last upgrade. In that instance, I was able to pull all the sql performing the schema upgrade (I THINK by tacking --dump-sql to the end of the db update command, then run, edit, and re-run every command until I got it to work. In that case, the issue was mostly actual errors in the upgrade SQL, but I believe there we a few references to non-existent objects, as here.

My guess is I can do something similar here, maybe by running “doctrine:schema:update --force --dump-sql”? But I thought it would be wise to post before doing anything. How do I get to a point I no longer have such problems at all? Seems like once the upgrade is complete, the next upgrade shouldn’t be asking for anything not in the schema.

Thanks
