# Mautic Migration errors version 2.16.0

**URL:** <https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935>\
**Category:** Product Support\
**Created:** [February 19, 2020, 8:27pm UTC](https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935 "2020-02-19T20:27:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsieber](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/jsieber/32/698_2.png) [@jsieber](https://forum.mautic.org/u/jsieber)\
**Post date:** [February 19, 2020, 8:27pm UTC](https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935/1 "2020-02-19T20:27:41Z")

</div>

**Your software**  
My Mautic version is: 2.16.0  
My PHP version is: 7.1.33

**Your problem**  
My problem is:

I received errors in my log file after the upgrade to 2.16.0.

[2020-02-19 00:10:36] mautic.ERROR: SCHEMA ERROR: An exception occurred while executing ‘SELECT f.alias, f.is\_unique\_identifer as is\_unique, f.type, f.object FROM ma\_lead\_fields f WHERE f.object = ‘lead’ ORDER BY f.field\_order ASC’: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘mautic.ma\_lead\_fields’ doesn’t exist    
[2020-02-19 19:16:53] mautic.NOTICE: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘ALTER TABLE ma\_lead\_event\_log DROP FOREIGN KEY FK\_3364E8F155458D’: SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ‘FK\_3364E8F155458D’; check that column/key exists (uncaught exception) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 while running console command `doctrine:migrations:migrate`

It appears that the first error is not an issue and has been around for a few errors. The second error seems to be a concern as I don’t think the migration is completing.

If I manually run the migration I get the following errors in regards to missing Foreign keys.

Migrating up to 20190715065013 from 20180220212444

++ migrating 20180329185634

```
 -> ALTER TABLE ma_lead_event_log DROP FOREIGN KEY FK_3364E8F155458D

```

Migration 20180329185634 failed during Execution. Error An exception occurred while executing ‘ALTER TABLE ma\_lead\_event\_log DROP FOREIGN KEY FK\_3364E8F155458D’:

SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ‘FK\_3364E8F155458D’; check that column/key exists

[Doctrine\DBAL\Exception\DriverException]  
An exception occurred while executing ‘ALTER TABLE ma\_lead\_event\_log  
DROP FOREIGN KEY FK\_3364E8F155458D’:

SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ’  
FK\_3364E8F155458D’; check that column/key exists

[Doctrine\DBAL\Driver\PDOException]  
SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ’  
FK\_3364E8F155458D’; check that column/key exists

[PDOException]  
SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ’  
FK\_3364E8F155458D’; check that column/key exists

Steps I have tried to fix the problem: I’ve tried running the migration over manually and consistently get these errors. Is the lack of these foreign keys causing the migration to fail? Is there a command I can run to fix these missing foreign keys?

---

<div class="post-metadata">

**Author:** ![ekke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ekke/32/296_2.png) [@ekke](https://forum.mautic.org/u/ekke)\
**Post date:** [February 19, 2020, 8:55pm UTC](https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935/2 "2020-02-19T20:55:11Z")

</div>

Did you try https:// mauticurl /s/update/schema ?

---

<div class="post-metadata">

**Author:** ![jsieber](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/jsieber/32/698_2.png) [@jsieber](https://forum.mautic.org/u/jsieber)\
**Post date:** [February 19, 2020, 11:45pm UTC](https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935/3 "2020-02-19T23:45:12Z")

</div>

Yes, it produces the same errors as running the migration task.

[2020-02-19 16:46:24] mautic.NOTICE: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘ALTER TABLE ma\_lead\_event\_log DROP FOREIGN KEY FK\_3364E8F155458D’: SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ‘FK\_3364E8F155458D’; check that column/key exists (uncaught exception) at /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 while running console command `doctrine:migrations:migrate`    
[2020-02-19 16:46:24] mautic.ERROR: [UPGRADE ERROR] Exit code 1; Mautic Migrations \ Migrating up to 20190715065013 from 20180220212444 \ ++ migrating 20180329185634 \ -\> ALTER TABLE ma\_lead\_event\_log DROP FOREIGN KEY FK\_3364E8F155458D Migration 20180329185634 failed during Execution. Error An exception occurred while executing ‘ALTER TABLE ma\_lead\_event\_log DROP FOREIGN KEY FK\_3364E8F155458D’: \ SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ‘FK\_3364E8F155458D’; check that column/key exists \ [Doctrine\DBAL\Exception\DriverException] An exception occurred while executing ‘ALTER TABLE ma\_lead\_event\_log DROP FOREIGN KEY FK\_3364E8F155458D’: \ SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ‘FK\_3364E8F155458D’; check that column/key exists \ [Doctrine\DBAL\Driver\PDOException] SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ‘FK\_3364E8F155458D’; check that column/key exists \ [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP ‘FK\_3364E8F155458D’; 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] [–] \

---

<div class="post-metadata">

**Author:** ![ekke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ekke/32/296_2.png) [@ekke](https://forum.mautic.org/u/ekke)\
**Post date:** [February 20, 2020, 8:05am UTC](https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935/4 "2020-02-20T08:05:39Z")

</div>

Out of curiosity: Did you do the initial upgrade via GUI, or via console command?

---

<div class="post-metadata">

**Author:** ![ekke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ekke/32/296_2.png) [@ekke](https://forum.mautic.org/u/ekke)\
**Post date:** [February 20, 2020, 8:13am UTC](https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935/5 "2020-02-20T08:13:39Z")

</div>

no guarantees, but you might try (a backup and then) run  
`ALTER TABLE 'lead_event_log' ADD CONSTRAINT 'FK_3364E8F155458D' FOREIGN KEY ('lead_id') REFERENCES 'lead_event_log'('id') ON DELETE CASCADE ON UPDATE RESTRICT;`

or rather, in your case  
`ALTER TABLE 'ma_lead_event_log' ADD CONSTRAINT 'FK_3364E8F155458D' FOREIGN KEY ('lead_id') REFERENCES 'ma_lead_event_log'('id') ON DELETE CASCADE ON UPDATE RESTRICT;`

and try `https:// mautic.url /s/update/schema` once again

---

<div class="post-metadata">

**Author:** ![jsieber](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/jsieber/32/698_2.png) [@jsieber](https://forum.mautic.org/u/jsieber)\
**Post date:** [February 20, 2020, 10:02pm UTC](https://forum.mautic.org/t/mautic-migration-errors-version-2-16-0/12935/6 "2020-02-20T22:02:33Z")

</div>

The upgrade was performed on the command line. The original database does not have this foreign key so I’m wondering if it was a failure on a previous upgrade.

In your example above, it is suppose to reference ‘ma\_leads’(‘id’) instead of ‘ma\_leads\_event\_log’(‘id’)?
