# Update to 4.1.1 failed

**URL:** <https://forum.mautic.org/t/update-to-4-1-1-failed/22165>\
**Category:** Mautic 4 Install/Upgrade Support\
**Created:** [December 26, 2021, 9:25pm UTC](https://forum.mautic.org/t/update-to-4-1-1-failed/22165 "2021-12-26T21:25:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter\_k](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/peter_k/32/511_2.png) [@peter\_k](https://forum.mautic.org/u/peter_k)\
**Post date:** [December 26, 2021, 9:25pm UTC](https://forum.mautic.org/t/update-to-4-1-1-failed/22165/1 "2021-12-26T21:25:24Z")

</div>

**Your software**  
_My PHP version is_ : 7.4  
_My MySQL version is_: 5.7.3

**Updating/Installing Errors**  
_I am_ (delete as applicable): Updating  
_Upgrading/installing via_ (delete as applicable) : Command Line

_These errors are showing in the installer_ :

```auto
$ php74 console mautic:update:apply
Are you sure you wish to update Mautic to the latest version? y
Step 5 [--->------------------------] Removing deleted files

<warning>IMPORTANT: Run the same command again with --finish. For example 'php bin/console mautic:update:apply --finish'</warning>

$ php74 console mautic:update:apply --finish
Step 2 [->--------------------------] Migrating database schema...

An error occurred while updating the database. Check log for more details.

```

_These errors are showing in the Mautic log_ :

```auto
 cat var/logs/mautic_prod-2021-12-26.php 
[2021-12-26 18:49:48] mautic.WARNING: Received SES webhook of type '' but couldn't understand payload [] []
[2021-12-26 19:46:23] mautic.WARNING: Received SES webhook of type '' but couldn't understand payload [] []
[2021-12-26 20:55:03] mautic.WARNING: Received SES webhook of type '' but couldn't understand payload [] []
[2021-12-26 21:03:03] mautic.WARNING: Received SES webhook of type '' but couldn't understand payload [] []
[2021-12-26 22:10:34] mautic.NOTICE: Doctrine\DBAL\Exception\TableExistsException: An exception occurred while executing ' CREATE TABLE mautic4campaign_summary ( id INT UNSIGNED AUTO_INCREMENT NOT NULL, campaign_id INT UNSIGNED DEFAULT NULL, event_id INT UNSIGNED NOT NULL, date_triggered DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', scheduled_count INT NOT NULL, triggered_count INT NOT NULL, non_action_path_taken_count INT NOT NULL, failed_count INT NOT NULL, log_counts_processed INT, INDEX IDX_E7708E49F639F774 (campaign_id), INDEX IDX_E7708E4971F7E88B (event_id), UNIQUE INDEX campaign_event_date_triggered (campaign_id, event_id, date_triggered), PRIMARY KEY(id) ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC; ': SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mautic4campaign_summary' already exists (uncaught exception) at /www/htdocs/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 57 while running console command `doctrine:migrations:migrate` [] []
[2021-12-26 22:10:34] mautic.WARNING: Command `doctrine:migrations:migrate` exited with status code 1 [] []
[2021-12-26 22:10:34] mautic.WARNING: Command `mautic:update:apply` exited with status code 1 [] []

```

_migration error_

```auto
$ php74 ./mautic/bin/console doctrine:migrations:migrate
                                                         
                    Mautic Migrations                    
                                                         

WARNING! You are about to execute a database migration that could result in schema changes and data loss. Are you sure you wish to continue? (y/n)y
Migrating up to 20210623071326 from 20201105120328

  ++ migrating 20201120122846

     -> 
            CREATE TABLE mautic4campaign_summary (
                id INT UNSIGNED AUTO_INCREMENT NOT NULL,
                campaign_id INT UNSIGNED DEFAULT NULL,
                event_id INT UNSIGNED NOT NULL,
                date_triggered DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)',
                scheduled_count INT NOT NULL,
                triggered_count INT NOT NULL,
                non_action_path_taken_count INT NOT NULL,
                failed_count INT NOT NULL,
                log_counts_processed INT,
                INDEX IDX_E7708E49F639F774 (campaign_id),
                INDEX IDX_E7708E4971F7E88B (event_id),
                UNIQUE INDEX campaign_event_date_triggered (campaign_id, event_id, date_triggered),
                PRIMARY KEY(id)
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;
Migration 20201120122846 failed during Execution. Error An exception occurred while executing '
            CREATE TABLE mautic4campaign_summary (
                id INT UNSIGNED AUTO_INCREMENT NOT NULL,
                campaign_id INT UNSIGNED DEFAULT NULL,
                event_id INT UNSIGNED NOT NULL,
                date_triggered DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)',
                scheduled_count INT NOT NULL,
                triggered_count INT NOT NULL,
                non_action_path_taken_count INT NOT NULL,
                failed_count INT NOT NULL,
                log_counts_processed INT,
                INDEX IDX_E7708E49F639F774 (campaign_id),
                INDEX IDX_E7708E4971F7E88B (event_id),
                UNIQUE INDEX campaign_event_date_triggered (campaign_id, event_id, date_triggered),
                PRIMARY KEY(id)
            ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;
        ':

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mautic4campaign_summary' already exists

In AbstractMySQLDriver.php line 57:
                                                                                                                  
  An exception occurred while executing '                                                                         
              CREATE TABLE mautic4campaign_summary (                                                              
                  id INT UNSIGNED AUTO_INCREMENT NOT NULL,                                                        
                  campaign_id INT UNSIGNED DEFAULT NULL,                                                          
                  event_id INT UNSIGNED NOT NULL,                                                                 
                  date_triggered DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)',                    
                  scheduled_count INT NOT NULL,                                                                   
                  triggered_count INT NOT NULL,                                                                   
                  non_action_path_taken_count INT NOT NULL,                                                       
                  failed_count INT NOT NULL,                                                                      
                  log_counts_processed INT,                                                                       
                  INDEX IDX_E7708E49F639F774 (campaign_id),                                                       
                  INDEX IDX_E7708E4971F7E88B (event_id),                                                          
                  UNIQUE INDEX campaign_event_date_triggered (campaign_id, event_id, date_triggered),             
                  PRIMARY KEY(id)                                                                                 
              ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;  
          ':                                                                                                      
                                                                                                                  
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mautic4campaign_summary' already exists         
                                                                                                                  

In Exception.php line 18:
                                                                                                           
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mautic4campaign_summary' already exists  
                                                                                                           

In PDOConnection.php line 132:
                                                                                                           
  SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mautic4campaign_summary' already exists

```

**Your problem**  
_My problem is_ :  
I installed Mautic a couple of days ago. I got the notification that an update was published. I tried to update via the CLI and got the above error.  
I guess, the database migration fails/failed.

I don’t know if that is a problem or if it can be ignored, because I installed 4.1.0 and therefore the migration isn’t necessary.

Web backend seems to run fine, but I don’t know whether I’m running in some problems in the future.

Regards

---

<div class="post-metadata">

**Author:** ![peter\_k](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/peter_k/32/511_2.png) [@peter\_k](https://forum.mautic.org/u/peter_k)\
**Post date:** [January 7, 2022, 1:50pm UTC](https://forum.mautic.org/t/update-to-4-1-1-failed/22165/2 "2022-01-07T13:50:45Z")

</div>

I fixed it myself now by dropping/deleting the `mautic4campaign_summary` table manually via PHPMyAdmin.

Nevertheless, I think the SQL in that migration should be `CREATE TABLE IF NOT EXISTS mautic4campaign_summary [...]`. This would prevent this error when the table is (for some reason) already existent.

I don’t know why the table existed, already, in the first place. I guess the production zip I used for installing added it to the database, but didn’t mark the migration as applied 🤷‍♂️

The failing migration would have prevented applying the rest of 10 outstanding migrations. Therefore, all futures migrations would have failed and prevented a proper update.

Hopefully this helps others.

PS: Check if the table is empty before dropping it. Mine was. And create a backup before doing it.
