**Please DO NOT report security vulnerabilities here. Send them to security@maut…ic.com instead.**
What type of report is this:
| Q | A
| ---| ---
| Bug report? | Yes
| Feature request? | No
| Enhancement? | No
## Description:
Attempting to update from self-hosted Mautic 2.12.1 to 2.13.1 fails using both the in-app upgrade process and SSH command line upgrade script.
Environment: VPS cPanel Easy Apache 4, CentOS Linux release 7.5.1804 (Core)
Installation of 2.12.1 was done via Softaculous installer and this is the first upgrade attempt.
## If a bug:
| Q | A
| --- | ---
| Mautic version | 2.12.1
| PHP version | 5.6.36
### Steps to reproduce:
1. Click on the "Update now" notification in the Mautic notification UI
2. Observe error message is displayed for the "Processing Database Updates":
![screenshot 2018-05-28 13 51 49](https://user-images.githubusercontent.com/863419/40629704-0cd7f2e6-6282-11e8-995e-49c615d7e714.png)
3. Follow the command line update instructions posted here:
[Uh Oh, Mautic upgrade was not successful](https://johnlinhart.com/blog/uh-oh-mautic-upgrade-was-not-successful)
4. Observe the errors produced when following command line session output:
Command Line Output:
```
[~/www/mautic]# php app/console cache:clear
// Clearing the cache for the prod environment with debug false
[OK] Cache for the "prod" environment (debug=false) was successfully cleared.
[~/www/mautic]# php app/console mautic:update:find
Great! You are running the current version of Mautic.
[~/www/mautic]# php app/console doctrine:migration:status
== Configuration
>> Name: Mautic Migrations
>> Database Driver: mysqli
>> Database Name: afonseca_mautic
>> Configuration Source: manually configured
>> Version Table Name: migrations
>> Version Column Name: version
>> Migrations Namespace: Mautic\Migrations
>> Migrations Directory: /home/afonseca/public_html/mautic/app/migrations
>> Previous Version: 2018-02-01 18:49:33 (20180201184933)
>> Current Version: 2018-02-20 21:24:44 (20180220212444)
>> Next Version: 2018-03-29 18:56:34 (20180329185634)
>> Latest Version: 2018-04-19 14:59:34 (20180419145934)
>> Executed Migrations: 103
>> Executed Unavailable Migrations: 0
>> Available Migrations: 109
>> New Migrations: 6
[~/www/mautic]# php app/console doctrine:migration:migrate
Mautic Migrations
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 20180419145934 from 20180220212444
++ migrating 20180329185634
-> ALTER TABLE lead_event_log DROP FOREIGN KEY FK_753AF2E55458D
Migration 20180329185634 failed during Execution. Error An exception occurred while executing 'ALTER TABLE lead_event_log DROP FOREIGN KEY FK_753AF2E55458D':
Can't DROP 'FK_753AF2E55458D'; check that column/key exists
[Doctrine\DBAL\Exception\DriverException]
An exception occurred while executing 'ALTER TABLE lead_event_log DROP FOREIGN KEY FK_753AF2E55458D':
Can't DROP 'FK_753AF2E55458D'; check that column/key exists
[Doctrine\DBAL\Driver\Mysqli\MysqliException]
Can't DROP 'FK_753AF2E55458D'; 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] [--] <command> [<version>]
```
### Log errors:
prod-2018-05-28.php
------------------------------------------------------------
```
[2018-05-28 20:51:04] doctrine.DEBUG: SELECT COLUMN_NAME AS Field, COLUMN_TYPE AS Type, IS_NULLABLE AS `Null`, COLUMN_KEY AS `Key`, COLUMN_DEFAULT AS `Default`, EXTRA AS Extra, COLUMN_COMMENT AS Comment, CHARACTER_SET_NAME AS CharacterSet, COLLATION_NAME AS Collation FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'afonseca_mautic' AND TABLE_NAME = 'widgets' [] []
[2018-05-28 20:51:04] doctrine.DEBUG: SELECT DISTINCT k.`CONSTRAINT_NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ FROM information_schema.key_column_usage k /*!50116 INNER JOIN information_schema.referential_constraints c ON c.constraint_name = k.constraint_name AND c.table_name = 'widgets' */ WHERE k.table_name = 'widgets' AND k.table_schema = 'afonseca_mautic' /*!50116 AND c.constraint_schema = 'afonseca_mautic' */ AND k.`REFERENCED_COLUMN_NAME` is not NULL [] []
[2018-05-28 20:51:04] doctrine.DEBUG: SELECT TABLE_NAME AS `Table`, NON_UNIQUE AS Non_Unique, INDEX_NAME AS Key_name, SEQ_IN_INDEX AS Seq_in_index, COLUMN_NAME AS Column_Name, COLLATION AS Collation, CARDINALITY AS Cardinality, SUB_PART AS Sub_Part, PACKED AS Packed, NULLABLE AS `Null`, INDEX_TYPE AS Index_Type, COMMENT AS Comment FROM information_schema.STATISTICS WHERE TABLE_NAME = 'widgets' AND TABLE_SCHEMA = 'afonseca_mautic' [] []
[2018-05-28 20:51:04] doctrine.DEBUG: "ROLLBACK" [] []
[2018-05-28 20:51:04] doctrine.DEBUG: INSERT INTO migrations (version) VALUES (?) ["20160225000000"] []
[2018-05-28 20:51:04] event.DEBUG: Notified event "console.terminate" to listener "Mautic\CoreBundle\EventListener\ConsoleTerminateListener::onConsoleTerminate". [] []
[2018-05-28 20:51:04] event.DEBUG: Notified event "console.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate". [] []
```
mautic_prod-2018-05-28.php
------------------------------------------------------------
```
[2018-05-28 20:51:03] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: "An exception occurred while executing 'SELECT l0_.id AS id_0, l0_.date_added AS date_added_1, l0_.client_info AS client_info_2, l0_.device AS device_3, l0_.device_os_name AS device_os_name_4, l0_.device_os_shortname AS device_os_shortname_5, l0_.device_os_version AS device_os_version_6, l0_.device_os_platform AS device_os_platform_7, l0_.device_brand AS device_brand_8, l0_.device_model AS device_model_9, l0_.device_fingerprint AS device_fingerprint_10, l0_.tracking_id AS tracking_id_11, l0_.lead_id AS lead_id_12 FROM lead_devices l0_ WHERE l0_.lead_id = ? AND l0_.tracking_id IS NOT NULL' with params [9598]: Unknown column 'l0_.tracking_id' in 'field list'" at /home/afonseca/public_html/mautic/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 l0_.id AS id_0, l0_.date_added AS date_added_1, l0_.client_info AS client_info_2, l0_.device AS device_3, l0_.device_os_name AS device_os_name_4, l0_.device_os_shortname AS device_os_shortname_5, l0_.device_os_version AS device_os_version_6, l0_.device_os_platform AS device_os_platform_7, l0_.device_brand AS device_brand_8, l0_.device_model AS device_model_9, l0_.device_fingerprint AS device_fingerprint_10, l0_.tracking_id AS tracking_id_11, l0_.lead_id AS lead_id_12 FROM lead_devices l0_ WHERE l0_.lead_id = ? AND l0_.tracking_id IS NOT NULL' with params [9598]:\n\nUnknown column 'l0_.tracking_id' in 'field list' at /home/afonseca/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:71, Doctrine\\DBAL\\Driver\\Mysqli\\MysqliException(code: 0): Unknown column 'l0_.tracking_id' in 'field list' at /home/afonseca/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php:101)"} []
[2018-05-28 13:51:58] mautic.NOTICE: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'ALTER TABLE lead_event_log DROP FOREIGN KEY FK_753AF2E55458D': Can't DROP 'FK_753AF2E55458D'; check that column/key exists (uncaught exception) at /home/afonseca/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 while running console command `doctrine:migrations:migrate` [] []
[2018-05-28 13:51:58] mautic.ERROR: [UPGRADE ERROR] Exit code 1; Mautic Migrations \ Migrating up to 20180419145934 from 20160225000000 \ 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) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20160615000000 \ -> DROP INDEX email_date_read ON email_stats -> CREATE INDEX email_date_read ON email_stats (date_read) \ ++ migrated (0.68s) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20160630000001 \ -> ALTER TABLE leads ADD CONSTRAINT FK_179045522298D193 FOREIGN KEY (stage_id) REFERENCES stages (id) ON DELETE SET NULL -> CREATE INDEX IDX_179045522298D193 ON leads (stage_id) \ ++ migrated (2.08s) \ ++ migrating 20160630000002 \ -> ALTER TABLE stages ADD CONSTRAINT FK_2FA26A6412469DE2 FOREIGN KEY (category_id) REFERENCES categories (id) ON DELETE SET NULL -> CREATE INDEX IDX_2FA26A6412469DE2 ON stages (category_id) -> ALTER TABLE leads DROP FOREIGN KEY FK_E4E3B6E2298D193 \ ++ migrated (0.88s) \ ++ migrating 20160712000000 \ -> UPDATE lead_fields SET properties = 'a:2:{s:9:"roundmode";s:1:"4";s:9:"precision";s:1:"2";}' WHERE alias = 'attribution' -> ALTER TABLE stages DROP FOREIGN KEY FK_D4C89D12469DE2 \ ++ migrated (0.58s) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20160720000000 \ -> DELETE FROM 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 (0.5s) \ 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 emails ADD CONSTRAINT FK_4C81E8529091A2FB FOREIGN KEY (translation_parent_id) REFERENCES emails (id) ON DELETE CASCADE -> CREATE INDEX IDX_4C81E8529091A2FB ON emails (translation_parent_id) -> ALTER TABLE emails ADD CONSTRAINT FK_4C81E85291861123 FOREIGN KEY (variant_parent_id) REFERENCES emails (id) ON DELETE CASCADE -> CREATE INDEX IDX_4C81E85291861123 ON emails (variant_parent_id) -> ALTER TABLE pages ADD CONSTRAINT FK_2074E5759091A2FB FOREIGN KEY (translation_parent_id) REFERENCES pages (id) ON DELETE CASCADE -> CREATE INDEX IDX_2074E5759091A2FB ON pages (translation_parent_id) -> ALTER TABLE pages ADD CONSTRAINT FK_2074E57591861123 FOREIGN KEY (variant_parent_id) REFERENCES pages (id) ON DELETE CASCADE -> CREATE INDEX IDX_2074E57591861123 ON pages (variant_parent_id) -> ALTER TABLE dynamic_content ADD CONSTRAINT FK_20B9DEB29091A2FB FOREIGN KEY (translation_parent_id) REFERENCES dynamic_content (id) ON DELETE CASCADE -> CREATE INDEX IDX_20B9DEB29091A2FB ON dynamic_content (translation_parent_id) -> ALTER TABLE dynamic_content ADD CONSTRAINT FK_20B9DEB291861123 FOREIGN KEY (variant_parent_id) REFERENCES dynamic_content (id) ON DELETE CASCADE -> CREATE INDEX IDX_20B9DEB291861123 ON dynamic_content (variant_parent_id) \ ++ migrated (0.63s) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20160731000000 \ -> update campaign_lead_event_log log inner join 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";}' -> ALTER TABLE dynamic_content DROP FOREIGN KEY FK_8BC619709091A2FB -> ALTER TABLE dynamic_content DROP FOREIGN KEY FK_8BC6197091861123 -> ALTER TABLE emails DROP FOREIGN KEY FK_63F74AAB9091A2FB -> ALTER TABLE emails DROP FOREIGN KEY FK_63F74AAB91861123 -> ALTER TABLE pages DROP FOREIGN KEY FK_39AA9B499091A2FB -> ALTER TABLE pages DROP FOREIGN KEY FK_39AA9B4991861123 \ ++ migrated (0.61s) \ 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 companies (companyname, is_published) (SELECT DISTINCT TRIM(company), 1 from leads l left join companies c ON l.company = c.companyname where company IS NOT NULL and company <> '' and c.companyname is null) -> insert into companies_leads (company_id, lead_id, date_added, manually_added, manually_removed) SELECT c.id, l.id, '2018-05-28 20:51:28', 0, 0 from leads l join companies c on c.companyname = l.company ON DUPLICATE KEY UPDATE company_id = c.id; \ ++ migrated (0.53s) \ 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) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20161123225456 \ Migration 20161123225456 was executed but did not result in any SQL statements. \ ++ migrated (0.56s) \ ++ migrating 20161124145649 \ -> ALTER TABLE lead_frequencyrules CHANGE `frequency_number` `frequency_number` SMALLINT DEFAULT NULL; -> ALTER TABLE lead_frequencyrules CHANGE `frequency_time` `frequency_time` VARCHAR(25) DEFAULT NULL; \ ++ migrated (0.51s) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20170108012944 \ -> ALTER TABLE push_notifications CHANGE button button LONGTEXT NULL -> ALTER TABLE dynamic_content_lead_data DROP FOREIGN KEY FK_C16B96AE55458D -> ALTER TABLE dynamic_content_lead_data CHANGE lead_id lead_id INT NOT NULL -> ALTER TABLE dynamic_content_lead_data ADD CONSTRAINT FK_515B221B55458D FOREIGN KEY (lead_id) REFERENCES leads (id) ON DELETE CASCADE \ ++ migrated (0.55s) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20170127205928 \ -> UPDATE `lead_fields` SET is_fixed = 1, type = 'timezone', date_modified = '2018-05-28 13:51:38' WHERE alias = 'timezone' -> CREATE INDEX timezone_search ON leads (timezone) \ ++ migrated (0.65s) \ 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) \ 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) \ 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) \ 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) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ SS skipped (Reason: Schema includes this migration) \ ++ migrating 20171208130606 \ -> ALTER TABLE lead_devices ADD tracking_id VARCHAR(255) DEFAULT NULL \ ++ migrated (1.84s) \ ++ migrating 20180105090000 \ -> ALTER TABLE pages CHANGE redirect_url redirect_url VARCHAR(2048) DEFAULT NULL; \ ++ migrated (0.7s) \ ++ migrating 20180117141613 \ -> ALTER TABLE tweets CHANGE text text VARCHAR(280) NOT NULL \ ++ migrated (0.66s) \ ++ migrating 20180201184933 \ -> ALTER TABLE assets ADD disallow TINYINT(1) NOT NULL; \ ++ migrated (0.68s) \ ++ migrating 20180220212444 \ -> ALTER TABLE pages ADD no_index tinyint(1) DEFAULT NULL \ ++ migrated (0.7s) \ ++ migrating 20180329185634 \ -> ALTER TABLE lead_event_log DROP FOREIGN KEY FK_753AF2E55458D Migration 20180329185634 failed during Execution. Error An exception occurred while executing 'ALTER TABLE lead_event_log DROP FOREIGN KEY FK_753AF2E55458D': \ Can't DROP 'FK_753AF2E55458D'; check that column/key exists \ [Doctrine\DBAL\Exception\DriverException] An exception occurred while executing 'ALTER TABLE lead_event_log DROP FOREIGN KEY FK_753AF2E55458D': \ Can't DROP 'FK_753AF2E55458D'; check that column/key exists \ [Doctrine\DBAL\Driver\Mysqli\MysqliException] Can't DROP 'FK_753AF2E55458D'; 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] [--] <command> [<version>] \ [] []
```