# Schema Update Fails + Campaign Errors

**URL:** <https://forum.mautic.org/t/schema-update-fails-campaign-errors/13096>\
**Category:** Product Support\
**Created:** [February 26, 2020, 7:29pm UTC](https://forum.mautic.org/t/schema-update-fails-campaign-errors/13096 "2020-02-26T19:29:42Z")\
**Posts on this page:** 1\
**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:** [February 26, 2020, 7:29pm UTC](https://forum.mautic.org/t/schema-update-fails-campaign-errors/13096/1 "2020-02-26T19:29:42Z")

</div>

**Your software**  
My Mautic version is: 2.16  
My PHP version is: 7.3

**Your problem**  
My problem is: Schema Update Fails + Campaign Errors

These errors are showing in the log:  
[Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException]  
An exception occurred while executing ‘ALTER TABLE mauhu\_lead\_companies\_change\_log ADD CONSTRAINT FK\_47567A9455458D FOREIGN KEY (lead\_id) REFERENCES mauhu\_leads (id) ON DELETE CASCADE’:

Cannot add or update a child row: a foreign key constraint fails (`admin_maut806`.`#sql-85e_f4d`, CONSTRAINT `FK_47567A9455458D` FOREIGN KEY (`lead_id`) REFERENCES `mauhu_leads` (`id`) ON DELETE CASCADE)

[Doctrine\DBAL\Driver\Mysqli\MysqliException]  
Cannot add or update a child row: a foreign key constraint fails (`admin_maut806`.`#sql-85e_f4d`, CONSTRAINT `FK_47567A9455458D` FOREIGN KEY (`lead_id`) REFERENCES `mauhu_leads` (`id`) ON DELETE CASCADE)

AND\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[2020-02-26 18:51:56] mautic.NOTICE: Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: An exception occurred while executing ‘ALTER TABLE mauhu\_lead\_companies\_change\_log ADD CONSTRAINT FK\_47567A9455458D FOREIGN KEY (lead\_id) REFERENCES mauhu\_leads (id) ON DELETE CASCADE’: Cannot add or update a child row: a foreign key constraint fails (`admin_maut806`.`#sql-85e_f19`, CONSTRAINT `FK_47567A9455458D` FOREIGN KEY (`lead_id`) REFERENCES `mauhu_leads` (`id`) ON DELETE CASCADE) (uncaught exception) at Mautic\_Install/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 60 while running console command `doctrine:schema:update`    
[2020-02-26 18:58:24] mautic.NOTICE: Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException: An exception occurred while executing ‘ALTER TABLE mauhu\_lead\_companies\_change\_log ADD CONSTRAINT FK\_47567A9455458D FOREIGN KEY (lead\_id) REFERENCES mauhu\_leads (id) ON DELETE CASCADE’: Cannot add or update a child row: a foreign key constraint fails (`admin_maut806`.`#sql-85e_f4d`, CONSTRAINT `FK_47567A9455458D` FOREIGN KEY (`lead_id`) REFERENCES `mauhu_leads` (`id`) ON DELETE CASCADE) (uncaught exception) at Mautic-Install/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 60 while running console command `doctrine:schema:update`

AND\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[2020-02-26 19:00:02] mautic.ERROR: CAMPAIGN: An exception occurred while executing ‘REPLACE INTO mauhu\_campaign\_lead\_event\_failed\_log( `log_id`, `date_added`, `reason`) SELECT id, :dateAdded as date\_added, :message as reason from mauhu\_campaign\_lead\_event\_log WHERE is\_scheduled = 1 AND lead\_id = :contactId AND campaign\_id = :campaignId AND rotation = :rotation’: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':dateAdded as date\_added, :message as reason from mauhu\_campaign\_lead\_event\_log ’ at line 2

AND\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\*doctrine:schema:validate  
[Mapping] FAIL - The entity-class ‘Mautic\DynamicContentBundle\Entity\DynamicContentLeadData’ mapping is invalid:

- The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which is not defined as association.
- The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which does not exist.

[Mapping] FAIL - The entity-class ‘Bazinga\OAuthServerBundle\Model\AccessToken’ mapping is invalid:

- The field ‘Bazinga\OAuthServerBundle\Model\AccessToken#expiresAt’ uses a non-existant type ‘int’.

[Mapping] FAIL - The entity-class ‘Bazinga\OAuthServerBundle\Model\RequestToken’ mapping is invalid:

- The field ‘Bazinga\OAuthServerBundle\Model\RequestToken#expiresAt’ uses a non-existant type ‘int’.

[Database] FAIL - The database schema is not in sync with the current mapping file.

AND\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[SQL DUMP](https://techphenomenon.com/files/public-docs/SQL-Dump.txt)

Steps I have tried to fix the problem: Followed these steps  
[https://johnlinhart.com/blog/uh-oh-mautic-upgrade-was-not-successful](https://johnlinhart.com/blog/uh-oh-mautic-upgrade-was-not-successful)  
[https://www.mautic.org/docs/en/tips/update-failed.html](https://www.mautic.org/docs/en/tips/update-failed.html)
