Mautic Community Forums

SQL Error upgrading to Mautic 4

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.