# FIXED - mautic.ERROR: CAMPAIGN: An exception occurred while executing ‘REPLACE INTO

**URL:** <https://forum.mautic.org/t/fixed-mautic-error-campaign-an-exception-occurred-while-executing-replace-into/15852>\
**Category:** Product Support\
**Created:** [August 28, 2020, 7:50pm UTC](https://forum.mautic.org/t/fixed-mautic-error-campaign-an-exception-occurred-while-executing-replace-into/15852 "2020-08-28T19:50:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gary.harrison](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gary.harrison/32/2864_2.png) [@gary.harrison](https://forum.mautic.org/u/gary.harrison)\
**Post date:** [August 28, 2020, 7:50pm UTC](https://forum.mautic.org/t/fixed-mautic-error-campaign-an-exception-occurred-while-executing-replace-into/15852/1 "2020-08-28T19:50:32Z")

</div>

_ **FIXED** _

I will leave this in case it helps others…

1. The field generated\_sent\_date was missing from the email\_stats. Manually added it in mysql
2. Had to change the mysql driver to “pdo\_mysql” in local.php

* * *

**Your software**  
My Mautic version is: 3.1.0  
My PHP version is: 7.3  
MY SQL version is: 5.7.31

**Your problem**  
My problem is: Campaigns Are Not Restarting

These errors are showing in the log: [2020-08-28 19:42:02] mautic.ERROR: CAMPAIGN: An exception occurred while executing ‘REPLACE INTO mau4s\_campaign\_lead\_event\_failed\_log( `log_id`, `date_added`, `reason`) SELECT id, :dateAdded as date\_added, :message as reason from mau4s\_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 MySQL server version for the right syntax to use near ':dateAdded as date\_added, :message as reason from mau4s\_campaign\_lead\_event\_log ’ at line 2

Steps I have tried to fix the problem: When i run s/update/schema i get the following error, so something is wrong with my database. This was a new install of 3.0.2 that was immediately upgraded to 3.1.0.

[2020-08-28 19:47:20] mautic.NOTICE: Doctrine\DBAL\Exception\SyntaxErrorException: An exception occurred while executing ‘ALTER TABLE mau4s\_email\_stats ADD generated\_sent\_date DATE AS (CONCAT(YEAR(date\_sent), “-”, LPAD(MONTH(date\_sent), 2, “0”), “-”, LPAD(DAY(date\_sent), 2, “0”))) COMMENT ‘(DC2Type:generated)’; ALTER TABLE mau4s\_email\_stats ADD INDEX `mau4s_generated_sent_date_email_id`(generated\_sent\_date, email\_id)’: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ALTER TABLE mau4s\_email\_stats ADD INDEX `mau4s_generated_sent_date_email_id`(gen’ at line 2 (uncaught exception) at /home/entice/ds.entice.cloud/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 79 while running console command `doctrine:migrations:migrate`    
[2020-08-28 19:47:20] mautic.WARNING: Command `doctrine:migrations:migrate` exited with status code 1    
[2020-08-28 19:47:20] mautic.ERROR: [UPGRADE ERROR] Exit code 1; ++ adding generated column generated\_sent\_date -\> ALTER TABLE mau4s\_email\_stats ADD generated\_sent\_date DATE AS (CONCAT(YEAR(date\_sent), “-”, LPAD(MONTH(date\_sent), 2, “0”), “-”, LPAD(DAY(date\_sent), 2, “0”))) COMMENT ‘(DC2Type:generated)’; ALTER TABLE mau4s\_email\_stats ADD INDEX `mau4s_generated_sent_date_email_id`(generated\_sent\_date, email\_id) \ In AbstractMySQLDriver.php line 79: \ An exception occurred while executing ‘ALTER TABLE mau4s\_email\_stats ADD ge nerated\_sent\_date DATE AS (CONCAT(YEAR(date\_sent), “-”, LPAD(MONTH(date\_sen t), 2, “0”), “-”, LPAD(DAY(date\_sent), 2, “0”))) COMMENT ‘(DC2Type:generate d)’; ALTER TABLE mau4s\_email\_stats ADD INDEX `mau4s_generated_sent_d ate_email_id`(generated\_sent\_date, email\_id)’: \ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ALTER TABLE mau 4s\_email\_stats ADD INDEX `mau4s_generated_sent_date_email_id`(gen’ at line 2 \ In MysqliStatement.php line 86: \ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ALTER TABLE mau 4s\_email\_stats ADD INDEX `mau4s_generated_sent_date_email_id`(gen’ at line 2 \ doctrine:migrations:migrate [–write-sql [WRITE-SQL]] [–dry-run] [–query-time] [–allow-no-migration] [–all-or-nothing [ALL-OR-NOTHING]] [–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] [-e|–env ENV] [–no-debug] [–] \

I’ve also tried changing the value of property ‘db\_driver’ from ‘mysqli’ to ‘db\_driver’ =\> ‘pdo\_mysql’, in app/config/local.php, but ran into the same problem when updating the schema

I should note that this feature worked in 3.0.0

Hi,

I have a campaign that is using the "Allow contacts to restart the campaign " option turned on. This is causing the error above and the campaigns are not restarting. Any help is appreciated

---

<div class="post-metadata">

**Author:** ![Rich](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rich/32/45_2.png) [@Rich](https://forum.mautic.org/u/Rich)\
**Post date:** [October 8, 2020, 2:37pm UTC](https://forum.mautic.org/t/fixed-mautic-error-campaign-an-exception-occurred-while-executing-replace-into/15852/2 "2020-10-08T14:37:35Z")

</div>

> [@gary.harrison](#):
>
> generated\_sent\_date

Gary, did you set the added field generated\_sent\_date as datetime? Also, do you know if this was taken care of in the last release of Mautic?

Thank you for your time and solution. Rich
