# Upgrade to 2.2.1, errors, debug, fix

**URL:** <https://forum.mautic.org/t/upgrade-to-2-2-1-errors-debug-fix/6229>\
**Category:** Product Support\
**Created:** [October 14, 2016, 12:53pm UTC](https://forum.mautic.org/t/upgrade-to-2-2-1-errors-debug-fix/6229 "2016-10-14T12:53:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danwaterloo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/danwaterloo/32/77_2.png) [@danwaterloo](https://forum.mautic.org/u/danwaterloo)\
**Post date:** [October 14, 2016, 12:53pm UTC](https://forum.mautic.org/t/upgrade-to-2-2-1-errors-debug-fix/6229/1 "2016-10-14T12:53:36Z")

</div>

I received the notice that Mautic 2.2.1 update was available, and tried the web interface for the update. It was stuck on the ‘deleting cache’ step, and never finished (by the way, this same thing happened on the upgrade to 2.2.0).  
  
  
  
After waiting for 30 minutes, I gave up and decided to browse the system. It worked partially. When I looked at the details of a contact (known or anonymous), the server gave me a ‘500 sever error’.  
  
  
  
Looking in the logs of the Mautic system , which are located in this directory: /mautic\_install\_directory/app/logs, I found the following files:

Quote:

[root@74-93-83-11-illinois logs]# ls -ltr  
total 1992  
-rw-r--r-- 1 apache apache 2571 Oct 8 18:26 mautic\_prod-2016-10-08.php  
-rw-r--r-- 1 apache apache 1040 Oct 9 09:11 mautic\_prod-2016-10-09.php  
-rw-r--r-- 1 apache apache 4485 Oct 10 17:07 mautic\_prod-2016-10-10.php  
-rw-r--r-- 1 apache apache 11499 Oct 11 17:29 mautic\_prod-2016-10-11.php  
-rw-r--r-- 1 apache apache 4522 Oct 12 12:31 mautic\_prod-2016-10-12.php  
-rw-r--r-- 1 apache apache 4249 Oct 13 11:07 mautic\_prod-2016-10-13.php  
-rw-r--r-- 1 apache apache 1961089 Oct 14 07:25 prod-2016-10-14.php  
-rw-r--r-- 1 apache apache 27951 Oct 14 08:40 mautic\_prod-2016-10-14.php

  
then looking at the end of the newest file (mautic\_prod-2016-10-14.php), I found this:  

Quote:

[2016-10-14 13:04:51] mautic.CRITICAL: Uncaught PHP Exception DoctrineDBALExceptionInvalidFieldNameException: "An exception occurred while executing 'SELECT stage\_id as stage FROM it\_lead\_stages\_change\_log ls WHERE lead\_id = ? ORDER BY date\_added DESC' with params [5503]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stage\_id' in 'field list'" at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 71 {"exception":"[object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing 'SELECT stage\_id as stage FROM it\_lead\_stages\_change\_log ls WHERE lead\_id = ? ORDER BY date\_added DESC' with params [5503]:nnSQLSTATE[42S22]: Column not found: 1054 Unknown column 'stage\_id' in 'field list' at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:71, Doctrine\DBAL\Driver\PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stage\_id' in 'field list' at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stage\_id' in 'field list' at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91)"} []

  
Picking out the error... Unknown column 'stage\_id' in 'field list' , I decided that the database was never upgraded properly, either on this current migration to 2.2.1, or an earlier one.  
  
Using the instructions on this page:  
  
https://github.com/mautic/mautic  
  
I found these database migration instructions:  

Code:

php app/console doctrine:migrations:migrate --env=prod

  
After logging into the command line on my self hosted server:  

Quote:

php app/console doctrine:migrations:migrate --env=prod  
PHP Warning: Module 'memcache' already loaded in Unknown on line 0  
  
Mautic Migrations  
  
  
WARNING! You have 4 previously executed migrations in the database that are not registered migrations.  
\>\> 2015-02-01 00:00:00 (20150201000000)  
\>\> 2015-02-25 00:00:00 (20150225000000)  
\>\> 2015-03-07 00:00:00 (20150307000000)  
\>\> 2015-03-10 00:00:00 (20150310000000)  
Are you sure you wish to continue? (y/n)y  
WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)y  
Migrating up to 20161004123446 from 20160712000001  
  
SS skipped (Reason: Schema includes this migration)  
  
++ migrating 20160720000000  
  
-\> DELETE FROM it\_lead\_utmtags WHERE utm\_campaign is null and utm\_content is null and utm\_medium is null and utm\_source is null and utm\_term is null  
  
++ migrated (1.1s)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
++ migrating 20160726000001  
  
-\> ALTER TABLE it\_emails DROP FOREIGN KEY FK\_160D6C949091A2FB  
-\> ALTER TABLE it\_emails ADD CONSTRAINT FK\_160D6C949091A2FB FOREIGN KEY (translation\_parent\_id) REFERENCES it\_emails (id) ON DELETE CASCADE  
-\> ALTER TABLE it\_emails DROP FOREIGN KEY FK\_160D6C9491861123  
-\> ALTER TABLE it\_emails ADD CONSTRAINT FK\_160D6C9491861123 FOREIGN KEY (variant\_parent\_id) REFERENCES it\_emails (id) ON DELETE CASCADE  
-\> ALTER TABLE it\_pages DROP FOREIGN KEY FK\_A92F388B9091A2FB  
-\> ALTER TABLE it\_pages ADD CONSTRAINT FK\_A92F388B9091A2FB FOREIGN KEY (translation\_parent\_id) REFERENCES it\_pages (id) ON DELETE CASCADE  
-\> ALTER TABLE it\_pages DROP FOREIGN KEY FK\_A92F388B91861123  
-\> ALTER TABLE it\_pages ADD CONSTRAINT FK\_A92F388B91861123 FOREIGN KEY (variant\_parent\_id) REFERENCES it\_pages (id) ON DELETE CASCADE  
-\> ALTER TABLE it\_dynamic\_content DROP FOREIGN KEY FK\_DEB684479091A2FB  
-\> ALTER TABLE it\_dynamic\_content ADD CONSTRAINT FK\_DEB684479091A2FB FOREIGN KEY (translation\_parent\_id) REFERENCES it\_dynamic\_content (id) ON DELETE CASCADE  
-\> ALTER TABLE it\_dynamic\_content DROP FOREIGN KEY FK\_DEB6844791861123  
-\> ALTER TABLE it\_dynamic\_content ADD CONSTRAINT FK\_DEB6844791861123 FOREIGN KEY (variant\_parent\_id) REFERENCES it\_dynamic\_content (id) ON DELETE CASCADE  
  
++ migrated (10.76s)  
  
SS skipped (Reason: Schema includes this migration)  
  
++ migrating 20160731000000  
  
-\> update it\_campaign\_lead\_event\_log log inner join it\_campaign\_events events on log.event\_id = events.id set log.metadata = 'a:0:{}' where events.type = 'email.send' and log.metadata = 'a:2:{s:6:"failed";i:1;s:6:"reason";s:50:"mautic.notification.campaign.failed.not\_subscribed";}'  
  
++ migrated (1.1s)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
SS skipped (Reason: Schema includes this migration)  
  
++ migrating 20160926182807  
  
-\> insert into it\_companies (companyname, is\_published) (SELECT DISTINCT TRIM(company), 1 from it\_leads l left join it\_companies c ON l.company = c.companyname where company IS NOT NULL and company \<\> '' and c.companyname is null)  
-\> insert into it\_companies\_leads (company\_id, lead\_id, date\_added, manually\_added, manually\_removed) SELECT c.id, l.id, '2016-10-14 13:06:49', 0, 0 from it\_leads l join it\_companies c on c.companyname = l.company ON DUPLICATE KEY UPDATE company\_id = c.id;  
  
++ migrated (1.24s)  
  
++ migrating 20161004080958  
  
-\> ALTER TABLE it\_asset\_downloads CHANGE referer referer LONGTEXT DEFAULT NULL  
-\> ALTER TABLE it\_form\_submissions CHANGE referer referer LONGTEXT NOT NULL  
-\> ALTER TABLE it\_lead\_utmtags CHANGE referer referer LONGTEXT DEFAULT NULL  
  
++ migrated (5.66s)  
  
++ migrating 20161004090629  
  
-\> CREATE INDEX it\_stat\_email\_search2 ON it\_email\_stats (lead\_id, email\_id)  
  
++ migrated (1.61s)  
  
++ migrating 20161004123446  
  
-\> ALTER TABLE it\_lead\_stages\_change\_log ADD stage\_id INT(11) NULL DEFAULT NULL;  
-\> ALTER TABLE it\_lead\_stages\_change\_log ADD CONSTRAINT FK\_C0EE6592298D193 FOREIGN KEY (stage\_id) REFERENCES it\_stages (id) ON DELETE CASCADE  
-\> CREATE INDEX IDX\_C0EE6592298D193 ON it\_lead\_stages\_change\_log (stage\_id)  
  
++ migrated (3.9s)  

* * *
  
++ finished in 25.37s  
++ 19 migrations executed  
++ 23 sql queries

  
Figuring that if all was fixed, it would not need to run the migration commands again, I ran the command again:  

Quote:

php app/console doctrine:migrations:migrate --env=prod  
PHP Warning: Module 'memcache' already loaded in Unknown on line 0  
  
Mautic Migrations  
  
  
WARNING! You have 4 previously executed migrations in the database that are not registered migrations.  
\>\> 2015-02-01 00:00:00 (20150201000000)  
\>\> 2015-02-25 00:00:00 (20150225000000)  
\>\> 2015-03-07 00:00:00 (20150307000000)  
\>\> 2015-03-10 00:00:00 (20150310000000)  
Are you sure you wish to continue? (y/n)y  
WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)y  
  
  
No migrations to execute.

  
  
All was fixed, and the system is up and running.  
  
Hope this helps someone with this or a similar problem.

---

<div class="post-metadata">

**Author:** ![danwaterloo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/danwaterloo/32/77_2.png) [@danwaterloo](https://forum.mautic.org/u/danwaterloo)\
**Post date:** [October 14, 2016, 12:53pm UTC](https://forum.mautic.org/t/upgrade-to-2-2-1-errors-debug-fix/6229/2 "2016-10-14T12:53:36Z")

</div>

I received the notice that Mautic 2.2.1 update was available, and tried the web interface for the update. It was stuck on the ‘deleting cache’ step, and never finished (by the way, this same thing happened on the upgrade to 2.2.0).

After waiting for 30 minutes, I gave up and decided to browse the system. It worked partially. When I looked at the details of a contact (known or anonymous), the server gave me a ‘500 sever error’.

Looking in the logs of the Mautic system , which are located in this directory: /mautic\_install\_directory/app/logs, I found the following files:

[quote][root@74-93-83-11-illinois logs]# ls -ltr  
total 1992  
-rw-r–r-- 1 apache apache 2571 Oct 8 18:26 mautic\_prod-2016-10-08.php  
-rw-r–r-- 1 apache apache 1040 Oct 9 09:11 mautic\_prod-2016-10-09.php  
-rw-r–r-- 1 apache apache 4485 Oct 10 17:07 mautic\_prod-2016-10-10.php  
-rw-r–r-- 1 apache apache 11499 Oct 11 17:29 mautic\_prod-2016-10-11.php  
-rw-r–r-- 1 apache apache 4522 Oct 12 12:31 mautic\_prod-2016-10-12.php  
-rw-r–r-- 1 apache apache 4249 Oct 13 11:07 mautic\_prod-2016-10-13.php  
-rw-r–r-- 1 apache apache 1961089 Oct 14 07:25 prod-2016-10-14.php  
-rw-r–r-- 1 apache apache 27951 Oct 14 08:40 mautic\_prod-2016-10-14.php[/quote]

then looking at the end of the newest file (mautic\_prod-2016-10-14.php), I found this:

> [@](#):
>
> [2016-10-14 13:04:51] mautic.CRITICAL: Uncaught PHP Exception DoctrineDBALExceptionInvalidFieldNameException: “An exception occurred while executing ‘SELECT stage\_id as stage FROM it\_lead\_stages\_change\_log ls WHERE lead\_id = ? ORDER BY date\_added DESC’ with params [5503]: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘stage\_id’ in ‘field list’” at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 71 {“exception”:“[object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing ‘SELECT stage\_id as stage FROM it\_lead\_stages\_change\_log ls WHERE lead\_id = ? ORDER BY date\_added DESC’ with params [5503]:nnSQLSTATE[42S22]: Column not found: 1054 Unknown column ‘stage\_id’ in ‘field list’ at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:71, Doctrine\DBAL\Driver\PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘stage\_id’ in ‘field list’ at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘stage\_id’ in ‘field list’ at /home/mautic1/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91)”}

Picking out the error… Unknown column ‘stage\_id’ in ‘field list’ , I decided that the database was never upgraded properly, either on this current migration to 2.2.1, or an earlier one.

Using the instructions on this page:

> **[GitHub - mautic/mautic: Mautic: Open Source Marketing Automation Software.](https://github.com/mautic/mautic)**
>
> Mautic: Open Source Marketing Automation Software. - GitHub - mautic/mautic: Mautic: Open Source Marketing Automation Software.

I found these database migration instructions:

```auto
php app/console doctrine:migrations:migrate --env=prod
```

After logging into the command line on my self hosted server:

[quote]php app/console doctrine:migrations:migrate --env=prod  
PHP Warning: Module ‘memcache’ already loaded in Unknown on line 0

```
                Mautic Migrations

```

WARNING! You have 4 previously executed migrations in the database that are not registered migrations.  
\>\> 2015-02-01 00:00:00 (20150201000000)  
\>\> 2015-02-25 00:00:00 (20150225000000)  
\>\> 2015-03-07 00:00:00 (20150307000000)  
\>\> 2015-03-10 00:00:00 (20150310000000)  
Are you sure you wish to continue? (y/n)y  
WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)y  
Migrating up to 20161004123446 from 20160712000001

SS skipped (Reason: Schema includes this migration)

++ migrating 20160720000000

```
 -> DELETE FROM it_lead_utmtags WHERE utm_campaign is null and utm_content is null and utm_medium is null and utm_source is null and utm_term is null

```

++ migrated (1.1s)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

++ migrating 20160726000001

```
 -> ALTER TABLE it_emails DROP FOREIGN KEY FK_160D6C949091A2FB
 -> ALTER TABLE it_emails ADD CONSTRAINT FK_160D6C949091A2FB FOREIGN KEY (translation_parent_id) REFERENCES it_emails (id) ON DELETE CASCADE
 -> ALTER TABLE it_emails DROP FOREIGN KEY FK_160D6C9491861123
 -> ALTER TABLE it_emails ADD CONSTRAINT FK_160D6C9491861123 FOREIGN KEY (variant_parent_id) REFERENCES it_emails (id) ON DELETE CASCADE
 -> ALTER TABLE it_pages DROP FOREIGN KEY FK_A92F388B9091A2FB
 -> ALTER TABLE it_pages ADD CONSTRAINT FK_A92F388B9091A2FB FOREIGN KEY (translation_parent_id) REFERENCES it_pages (id) ON DELETE CASCADE
 -> ALTER TABLE it_pages DROP FOREIGN KEY FK_A92F388B91861123
 -> ALTER TABLE it_pages ADD CONSTRAINT FK_A92F388B91861123 FOREIGN KEY (variant_parent_id) REFERENCES it_pages (id) ON DELETE CASCADE
 -> ALTER TABLE it_dynamic_content DROP FOREIGN KEY FK_DEB684479091A2FB
 -> ALTER TABLE it_dynamic_content ADD CONSTRAINT FK_DEB684479091A2FB FOREIGN KEY (translation_parent_id) REFERENCES it_dynamic_content (id) ON DELETE CASCADE
 -> ALTER TABLE it_dynamic_content DROP FOREIGN KEY FK_DEB6844791861123
 -> ALTER TABLE it_dynamic_content ADD CONSTRAINT FK_DEB6844791861123 FOREIGN KEY (variant_parent_id) REFERENCES it_dynamic_content (id) ON DELETE CASCADE

```

++ migrated (10.76s)

SS skipped (Reason: Schema includes this migration)

++ migrating 20160731000000

```
 -> update it_campaign_lead_event_log log inner join it_campaign_events events on log.event_id = events.id set log.metadata = 'a:0:{}' where events.type = 'email.send' and log.metadata = 'a:2:{s:6:"failed";i:1;s:6:"reason";s:50:"mautic.notification.campaign.failed.not_subscribed";}'

```

++ migrated (1.1s)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

SS skipped (Reason: Schema includes this migration)

++ migrating 20160926182807

```
 -> insert into it_companies (companyname, is_published) (SELECT DISTINCT TRIM(company), 1 from it_leads l left join it_companies c ON l.company = c.companyname where company IS NOT NULL and company <> '' and c.companyname is null)
 -> insert into it_companies_leads (company_id, lead_id, date_added, manually_added, manually_removed) SELECT c.id, l.id, '2016-10-14 13:06:49', 0, 0 from it_leads l join it_companies c on c.companyname = l.company ON DUPLICATE KEY UPDATE company_id = c.id;

```

++ migrated (1.24s)

++ migrating 20161004080958

```
 -> ALTER TABLE it_asset_downloads CHANGE referer referer LONGTEXT DEFAULT NULL
 -> ALTER TABLE it_form_submissions CHANGE referer referer LONGTEXT NOT NULL
 -> ALTER TABLE it_lead_utmtags CHANGE referer referer LONGTEXT DEFAULT NULL

```

++ migrated (5.66s)

++ migrating 20161004090629

```
 -> CREATE INDEX it_stat_email_search2 ON it_email_stats (lead_id, email_id)

```

++ migrated (1.61s)

++ migrating 20161004123446

```
 -> ALTER TABLE it_lead_stages_change_log ADD stage_id INT(11) NULL DEFAULT NULL;
 -> ALTER TABLE it_lead_stages_change_log ADD CONSTRAINT FK_C0EE6592298D193 FOREIGN KEY (stage_id) REFERENCES it_stages (id) ON DELETE CASCADE
 -> CREATE INDEX IDX_C0EE6592298D193 ON it_lead_stages_change_log (stage_id)

```

++ migrated (3.9s)

* * *

++ finished in 25.37s  
++ 19 migrations executed  
++ 23 sql queries[/quote]

Figuring that if all was fixed, it would not need to run the migration commands again, I ran the command again:

[quote]php app/console doctrine:migrations:migrate --env=prod  
PHP Warning: Module ‘memcache’ already loaded in Unknown on line 0

```
                Mautic Migrations

```

WARNING! You have 4 previously executed migrations in the database that are not registered migrations.  
\>\> 2015-02-01 00:00:00 (20150201000000)  
\>\> 2015-02-25 00:00:00 (20150225000000)  
\>\> 2015-03-07 00:00:00 (20150307000000)  
\>\> 2015-03-10 00:00:00 (20150310000000)  
Are you sure you wish to continue? (y/n)y  
WARNING! You are about to execute a database migration that could result in schema changes and data lost. Are you sure you wish to continue? (y/n)y

No migrations to execute.[/quote]

All was fixed, and the system is up and running.

Hope this helps someone with this or a similar problem.
