# Problems with Mautic 3 migration - M2 database migration fails with error about foreign key

**URL:** <https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798>\
**Category:** Mautic 3 - Install/Upgrade Support\
**Created:** [June 16, 2020, 3:16am UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798 "2020-06-16T03:16:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [June 16, 2020, 3:16am UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/1 "2020-06-16T03:16:29Z")

</div>

My Mautic version is:2.16.3—\> 3.0  
My PHP version is:7.3

**Your problem**  
My problem is:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/c/c51d37ae839adaa9d1b122d19df5c346a6d4f904.jpeg)

These errors are showing in the log: ERR\_MAUTIC\_2\_MIGRATIONS\_FAILED: Oh no! While preparing the upgrade, the so-called ‘database migrations’ for Mautic 2 have failed. Command output: Mautic Migrations Migrating up to 20180329185634 from 20180220212444 ++ migrating 20180329185634 -\> ALTER TABLE mau7d\_lead\_event\_log DROP FOREIGN KEY FK\_FF95657C55458D Migration 20180329185634 failed during Execution. Error An exception occurred while executing ‘ALTER TABLE mau7d\_lead\_event\_log DROP FOREIGN KEY FK\_FF95657C55458D’: Can’t DROP ‘FK\_FF95657C55458D’; check that column/key exists [Doctrine\DBAL\Exception\DriverException] An exception occurred while executing ‘ALTER TABLE mau7d\_lead\_event\_log DROP FOREIGN KEY FK\_FF95657C55458D’: Can’t DROP ‘FK\_FF95657C55458D’; check that column/key exists [Doctrine\DBAL\Driver\Mysqli\MysqliException] Can’t DROP ‘FK\_FF95657C55458D’; check that column/key exists doctrine:migrations:migrate [–write-sql] [–dry-run] [–query-time] [–allow-no-migration] [–configuration [CONFIGURATION]] [–db-configuration [DB-CONFIGURATION]] [–db DB] [–em EM] [–shard SHARD] [-h|–help] [-q|–quiet] [-v|vv|vvv|–verbose] [-V|–version] [–ansi] [–no-ansi] [-n|–no-interaction] [-s|–shell] [–process-isolation] [-e|–env ENV] [–no-debug] [–] .

Steps I have tried to fix the problem:examined documentation concerning inverse operation of (x/y squared) x pi = q

Put a splint on the bone that broke that holds all the curse words in.

Drank coffee  
Walked my dog

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/c/c47b3a13c6fb123edd8fc45c3b7624b6e81a5084.jpeg)

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [June 16, 2020, 6:47am UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/2 "2020-06-16T06:47:18Z")

</div>

Moved to an individual topic instead of a reply to the category description 🙂

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [June 16, 2020, 10:12am UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/3 "2020-06-16T10:12:32Z")

</div>

Hi there,

Looks like this is an issue with one of the migration scripts in the past.

I found a [thread on a Github issue](https://github.com/mautic/mautic/issues/6134) related to this which suggests it is related to a Softaculous install - was yours originnally installed that way?

Here is the proposed solution: [https://github.com/mautic/mautic/issues/6134#issuecomment-437827628](https://github.com/mautic/mautic/issues/6134#issuecomment-437827628)

Can you give it a try and let us know?

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [June 16, 2020, 10:52pm UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/4 "2020-06-16T22:52:07Z")

</div>

Upgraded MariaDb today from 10.1 to 10.3. Will install a fresh instance of 2.16.2 —\> 2.16.3–\> 3.0 this evening or tomorrow. Will update post on the progress.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/0/000dd67141a2ba1716dfee47e7e1df174c2648a1.jpeg)

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [June 17, 2020, 3:12am UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/5 "2020-06-17T03:12:19Z")

</div>

![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/a/a84c020a75030c410857dd3b08a119d6a3ab9bd8.jpeg)  
Weird space in the error output but didn’t seem relevant to upgrade.  
Manually cleared cache  
Hit refresh  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/7/71bd6cc9702152b6048a8f58c74f4983a776da71.jpeg)

I’ll check logs in the morning and post anything relevant

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/e/e09f4e573afd5977a249711cfd913232b848dfca.jpeg)

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [June 17, 2020, 6:30am UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/6 "2020-06-17T06:30:23Z")

</div>

Glad to hear that your migration completed! If the cache creation stage failed it would mean a slow first load, but you can get in, it does not seem to have had a negative impact.

From what I can see of the error code it looks like there are some open\_basedir restrictions in place on your hosting environment so guessing that is the problem.

Feel free to

 ![WhatsApp Image 2020-06-15 at 09.47.51](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/6b47bf44fbab5cb1fc8ea1ce32d3bf346b0469d7.jpeg)

reach out with any further questions relating to the upgrade 😉 but going to mark as solved - was it the suggestion from Github that fixed the issue in the end?

---

<div class="post-metadata">

**Author:** ![EJL](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ejl/32/12155_2.png) [@EJL](https://forum.mautic.org/u/EJL)\
**Post date:** [June 17, 2020, 2:00pm UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/7 "2020-06-17T14:00:46Z")

</div>

adding the key as described solved an error but generated another with its reference to company Id In one table and lead Id in another (cascade on delete restrict on update). Oddly it was same foreign key so when viewing the relational view in myphp and adding another foreign key I never found a combination that allowed a schema update via command line.

I rolled back to 2.16.2 using a snapshot and upgraded mariadb from 10.1.45 to 10.3. Used GUI to upgrade this particular instance to progress from 2.16.2 —\>2.16.3–\> 3.0  
I was never able to address the error manually so I cannot say if upgrading Maria was the fix or not

---

<div class="post-metadata">

**Author:** ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)\
**Post date:** [June 22, 2020, 10:40am UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/8 "2020-06-22T10:40:11Z")

</div>

@EJL Mautic 3 requires MariaDB 10.2 or higher, so that might have caused some issues. We’ll be upgrading the upgrade script to mark MariaDB 10.2 (or MySQL 5.7) as the minimum required database version:

> [@Upgrade Error From 2.16.2 to 3.x](https://forum.mautic.org/t/upgrade-error-from-2-16-2-to-3-x/14663/16):
>
> Thanks for reporting back. We have taken the following steps to improve MariaDB support: [Add MariaDB to our CI testing pipeline](https://github.com/mautic/mautic/pull/8930)[Check for MariaDB 10.2+ (instead of 10.1+) in the Mautic 3 upgrade script](https://github.com/mautic/mautic/issues/8931)[Check if you’re running a supported database version in the clean installation process](https://forum.mautic.org/t/include-database-version-test-in-installer/14872) I will go ahead and close this topic now. If you came across any other issues, please feel free to let us know in a new topic slight_smile

---

<div class="post-metadata">

**Author:** ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)\
**Post date:** [June 23, 2020, 7:13pm UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/9 "2020-06-23T19:13:50Z")

</div>

@EJL regarding the `open_basedir` warning: we have found the issue and the fix is ready to be tested:

> <https://github.com/mautic/mautic/pull/8941>

Thanks for reporting this issue 🚀

---

<div class="post-metadata">

**Author:** ![marciosantos](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/marciosantos/32/2434_2.png) [@marciosantos](https://forum.mautic.org/u/marciosantos)\
**Post date:** [June 30, 2021, 6:28pm UTC](https://forum.mautic.org/t/problems-with-mautic-3-migration-m2-database-migration-fails-with-error-about-foreign-key/14798/10 "2021-06-30T18:28:14Z")

</div>

Hi im having trouble with my mautic installation. I’m trying to update and I think my mautic is in between versions 2.6 and 3 because after I began the upgrade from 2.6 it stalled.

I setup the commands.php file as [described here](https://gist.github.com/escopecz/9a1a0b10861941a457f4):

and when I run any of the commands I see this:

**Fatal error** : Uncaught Error: Class ‘Symfony\Component\HttpKernel\Kernel’ not found in
