Mautic update failed

Your software
My Mautic version is: v2.15.3
My PHP version is: 7.1.33

Your problem
My problem is:
The update failed. The database didn’t update properly.
Now I can’t access Forms, and users can’t submit forms.
I have tried to update the database with the my-mautic-url/s/update/schema
With the error message:
An error occurred while updating the database. Check log for more details.

These errors are showing in the log:
[2019-11-29 13:24:42] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: “An exception occurred while executing ‘SELECT COUNT() AS dctrn_count FROM (SELECT DISTINCT id_10 FROM (SELECT m0_.is_published AS is_published_0, m0_.date_added AS date_added_1, m0_.created_by AS created_by_2, m0_.created_by_user AS created_by_user_3, m0_.date_modified AS date_modified_4, m0_.modified_by AS modified_by_5, m0_.modified_by_user AS modified_by_user_6, m0_.checked_out AS checked_out_7, m0_.checked_out_by AS checked_out_by_8, m0_.checked_out_by_user AS checked_out_by_user_9, m0_.id AS id_10, m0_.name AS name_11, m0_.description AS description_12, m0_.alias AS alias_13, m0_.form_attr AS form_attr_14, m0_.cached_html AS cached_html_15, m0_.post_action AS post_action_16, m0_.post_action_property AS post_action_property_17, m0_.publish_up AS publish_up_18, m0_.publish_down AS publish_down_19, m0_.template AS template_20, m0_.in_kiosk_mode AS in_kiosk_mode_21, m0_.render_style AS render_style_22, m0_.form_type AS form_type_23, m0_.no_index AS no_index_24, (SELECT count(m1_.id) AS dctrn__1 FROM maumi_form_submissions m1_ WHERE m1_.form_id = m0_.id) AS sclr_25 FROM maumi_forms m0_ LEFT JOIN maumi_categories m2_ ON m0_.category_id = m2_.id ORDER BY m0_.name ASC) dctrn_result) dctrn_table’: Unknown column ‘m0_.form_attr’ in ‘field list’" at /home/virtu149/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 COUNT() AS dctrn_count FROM (SELECT DISTINCT id_10 FROM (SELECT m0_.is_published AS is_published_0, m0_.date_added AS date_added_1, m0_.created_by AS created_by_2, m0_.created_by_user AS created_by_user_3, m0_.date_modified AS date_modified_4, m0_.modified_by AS modified_by_5, m0_.modified_by_user AS modified_by_user_6, m0_.checked_out AS checked_out_7, m0_.checked_out_by AS checked_out_by_8, m0_.checked_out_by_user AS checked_out_by_user_9, m0_.id AS id_10, m0_.name AS name_11, m0_.description AS description_12, m0_.alias AS alias_13, m0_.form_attr AS form_attr_14, m0_.cached_html AS cached_html_15, m0_.post_action AS post_action_16, m0_.post_action_property AS post_action_property_17, m0_.publish_up AS publish_up_18, m0_.publish_down AS publish_down_19, m0_.template AS template_20, m0_.in_kiosk_mode AS in_kiosk_mode_21, m0_.render_style AS render_style_22, m0_.form_type AS form_type_23, m0_.no_index AS no_index_24, (SELECT count(m1_.id) AS dctrn__1 FROM maumi_form_submissions m1_ WHERE m1_.form_id = m0_.id) AS sclr_25 FROM maumi_forms m0_ LEFT JOIN maumi_categories m2_ ON m0_.category_id = m2_.id ORDER BY m0_.name ASC) dctrn_result) dctrn_table’:\n\nUnknown column ‘m0_.form_attr’ in ‘field list’ at /home/virtu149/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:71, Doctrine\DBAL\Driver\Mysqli\MysqliException(code: 0): Unknown column ‘m0_.form_attr’ in ‘field list’ at /home/virtu149/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php:101)”}
[2019-11-29 13:27:55] mautic.NOTICE: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: Can’t write; duplicate key in table ‘#sql-201f_424150’ (uncaught exception) at /home/virtu149/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 while running console command doctrine:migrations:migrate
[2019-11-29 13:27:55] mautic.ERROR: [UPGRADE ERROR] Exit code 1; Mautic Migrations \ Migrating up to 20190715065013 from 20160630000000 \ ++ migrating 20160630000001 \ -> ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL Migration 20160630000001 failed during Execution. Error An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: \ Can’t write; duplicate key in table ‘#sql-201f_424150’ \ [Doctrine\DBAL\Exception\DriverException] An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: \ Can’t write; duplicate key in table ‘#sql-201f_424150’ \ [Doctrine\DBAL\Driver\Mysqli\MysqliException] Can’t write; duplicate key in table ‘#sql-201f_424150’ \ 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] [–] [] \
[2019-11-29 13:29:40] mautic.NOTICE: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: Can’t write; duplicate key in table ‘#sql-201f_4243d7’ (uncaught exception) at /home/virtu149/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 while running console command doctrine:migrations:migrate
[2019-11-29 13:29:40] mautic.ERROR: [UPGRADE ERROR] Exit code 1; Mautic Migrations \ Migrating up to 20190715065013 from 20160630000000 \ ++ migrating 20160630000001 \ -> ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL Migration 20160630000001 failed during Execution. Error An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: \ Can’t write; duplicate key in table ‘#sql-201f_4243d7’ \ [Doctrine\DBAL\Exception\DriverException] An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: \ Can’t write; duplicate key in table ‘#sql-201f_4243d7’ \ [Doctrine\DBAL\Driver\Mysqli\MysqliException] Can’t write; duplicate key in table ‘#sql-201f_4243d7’ \ 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] [–] [] \
[2019-11-29 13:29:40] mautic.ERROR: PHP Notice: require(): Failed opening required ‘/home/virtu149/public_html/mautic/app/cache/prod/doctrine/orm/Proxies/CG__MauticPluginBundleEntityPlugin.php’ (include_path=’.:/usr/local/php71/pear’) - in file /home/virtu149/public_html/mautic/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php - at line 209 [] []
[2019-11-29 13:29:40] mautic.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Notice: require(): Failed opening required '/home/virtu149/public_html/mautic/app/cache/prod/doctrine/orm/Proxies/CG__MauticPluginBundleEntityPlugin.php’ (include_path=’.:/usr/local/php71/pear’) - in file /home/virtu149/public_html/mautic/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php - at line 209 [] []
[2019-11-29 13:29:40] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: "Compile Error: require(): Failed opening required '/home/virtu149/public_html/mautic/app/cache/prod/doctrine/orm/Proxies/CG__MauticPluginBundleEntityPlugin.php’ (include_path=’.:/usr/local/php71/pear’)" at /home/virtu149/public_html/mautic/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php line 209 {“exception”:"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Compile Error: require(): Failed opening required '/home/virtu149/public_html/mautic/app/cache/prod/doctrine/orm/Proxies/CG__MauticPluginBundleEntityPlugin.php’ (include_path=’.:/usr/local/php71/pear’) at /home/virtu149/public_html/mautic/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:209)"} []
[2019-11-29 13:30:10] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: "An exception occurred while executing 'SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_10 FROM (SELECT m0
.is_published AS is_published_0, m0
.date_added AS date_added_1, m0
.created_by AS created_by_2, m0
.created_by_user AS created_by_user_3, m0
.date_modified AS date_modified_4, m0
.modified_by AS modified_by_5, m0
.modified_by_user AS modified_by_user_6, m0
.checked_out AS checked_out_7, m0_.checked_out_by AS checked_out_by_8, m0_.checked_out_by_user AS checked_out_by_user_9, m0_.id AS id_10, m0_.name AS name_11, m0_.description AS description_12, m0_.alias AS alias_13, m0_.form_attr AS form_attr_14, m0_.cached_html AS cached_html_15, m0_.post_action AS post_action_16, m0_.post_action_property AS post_action_property_17, m0_.publish_up AS publish_up_18, m0_.publish_down AS publish_down_19, m0_.template AS template_20, m0_.in_kiosk_mode AS in_kiosk_mode_21, m0_.render_style AS render_style_22, m0_.form_type AS form_type_23, m0_.no_index AS no_index_24, (SELECT count(m1_.id) AS dctrn__1 FROM maumi_form_submissions m1_ WHERE m1_.form_id = m0_.id) AS sclr_25 FROM maumi_forms m0_ LEFT JOIN maumi_categories m2_ ON m0_.category_id = m2_.id ORDER BY m0_.name ASC) dctrn_result) dctrn_table’: Unknown column ‘m0_.form_attr’ in ‘field list’" at /home/virtu149/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 COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_10 FROM (SELECT m0_.is_published AS is_published_0, m0_.date_added AS date_added_1, m0_.created_by AS created_by_2, m0_.created_by_user AS created_by_user_3, m0_.date_modified AS date_modified_4, m0_.modified_by AS modified_by_5, m0_.modified_by_user AS modified_by_user_6, m0_.checked_out AS checked_out_7, m0_.checked_out_by AS checked_out_by_8, m0_.checked_out_by_user AS checked_out_by_user_9, m0_.id AS id_10, m0_.name AS name_11, m0_.description AS description_12, m0_.alias AS alias_13, m0_.form_attr AS form_attr_14, m0_.cached_html AS cached_html_15, m0_.post_action AS post_action_16, m0_.post_action_property AS post_action_property_17, m0_.publish_up AS publish_up_18, m0_.publish_down AS publish_down_19, m0_.template AS template_20, m0_.in_kiosk_mode AS in_kiosk_mode_21, m0_.render_style AS render_style_22, m0_.form_type AS form_type_23, m0_.no_index AS no_index_24, (SELECT count(m1_.id) AS dctrn__1 FROM maumi_form_submissions m1_ WHERE m1_.form_id = m0_.id) AS sclr_25 FROM maumi_forms m0_ LEFT JOIN maumi_categories m2_ ON m0_.category_id = m2_.id ORDER BY m0_.name ASC) dctrn_result) dctrn_table’:\n\nUnknown column ‘m0_.form_attr’ in ‘field list’ at /home/virtu149/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:71, Doctrine\DBAL\Driver\Mysqli\MysqliException(code: 0): Unknown column ‘m0_.form_attr’ in ‘field list’ at /home/virtu149/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php:101)"}
[2019-11-29 13:30:17] mautic.NOTICE: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: Can’t write; duplicate key in table ‘#sql-201f_42450b’ (uncaught exception) at /home/virtu149/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 while running console command doctrine:migrations:migrate
[2019-11-29 13:30:17] mautic.ERROR: [UPGRADE ERROR] Exit code 1; Mautic Migrations \ Migrating up to 20190715065013 from 20160630000000 \ ++ migrating 20160630000001 \ -> ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL Migration 20160630000001 failed during Execution. Error An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: \ Can’t write; duplicate key in table ‘#sql-201f_42450b’ \ [Doctrine\DBAL\Exception\DriverException] An exception occurred while executing ‘ALTER TABLE maumi_leads ADD CONSTRAINT FK_D7C37362298D193 FOREIGN KEY (stage_id) REFERENCES maumi_stages (id) ON DELETE SET NULL’: \ Can’t write; duplicate key in table ‘#sql-201f_42450b’ \ [Doctrine\DBAL\Driver\Mysqli\MysqliException] Can’t write; duplicate key in table ‘#sql-201f_42450b’ \ 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] [–] [] \

How could I fix this?
Thanks,
Davor

1 Like

Hi Davor, and welcome to the forums!

Sorry to hear you’re having a problem after a failed update.

Have you run through the steps listed here: https://www.mautic.org/docs/en/tips/update-failed.html?

Let us know if you get any errors when working through that list of steps.

Thanks I have manually added a missing field to the database.
The field was: form_attr
Table: maumi_forms

SQL Script:
ALTER TABLE maumi_forms ADD form_attr VARCHAR(255) DEFAULT NULL

4 Likes

Thank you very much @dageci for sharing back the solution. You are indeed a community loving Mautician!

2 Likes

Thanks @Yosu_Cadilla, hope that it will also help someone.
:innocent:

2 Likes

Hi Ruth
is there a less daunting way of fixing a failed update. Unfortunately I am not a programmer and this is all double dutch to me.

Thanks
Monika

Hello @monika, try this method, it’s quite similar to the one Ruth pointed out but maybe a bit more accessible?

thank you I’ll take a look @Yosu_Cadilla

I have had a look and I am wondering if you can tell me please where do I check this

php /var/www/html/app/console doctrine:migration:migrate - is it inside of cPanel or whereabouts

thank you @Yosu_Cadilla

@monika These are Command Line Instructions, to be issued on your server. You need to login to your server to issue them.

  • If your OS is Linux just launch the “terminal” and connect to your server using SSH.
  • If you are on Windows you can use this tool: https://mremoteng.org/download

I would recommend you not to use Cpanel to host your Mautic instance and install it via SSH instead.

Here’s why you would want to do so:

Here’s how you can install Mautic with SSH:

Thank you - do you suggest that I uninstall and reinstall via SSH @Yosu_Cadilla

If you are going to be administering your own Mautic server, installing it yourself (instead of using panels or other tools) is indeed a good and solid starting point.

About uninstalling, probably not worth the trouble, you can simply launch a new VPS, install Mautic and import the database afterward.

However, keep in mind I don’t know the current state of your setup, so I can’t “recommend” you a specific course of action, I can only give you guidelines based on my experience and the experience of other Mauticians.

Thank you @Yosu_Cadilla yes you are correct, I did install it via Softalicious (or similar). I have connected it to Mailgun but it is proving more difficult to connect it to Elementor Page builder and being able to import the form fields into Mautic. I may have bitten off more than I can chew with this one. It seems to be written for programmers and not super user friendly.

Thank you though for your help.

I think there’s a video on Youtube about Mautic, forms and elementor, might be quite old but should provide some insight anyway.

If the integration is getting too complex, just don’t use the WP-Mautic plugin or any other integration, for the forms, create your forms directly in WP (or using any plugin you wish for the forms) and then integrate those forms manually in the page’s code so you don’t have interference with elementor.

1 Like

thank you @Yosu_Cadilla - I am still here and it won’t beat me lol.

1 Like

Power to you! let us know if you find any more issues…

PERFECT!
Thank you very much.

Is this recommendation still valid as Nov-2020?

I´m pretty new to Mautic. I installed it through Softaculus just 3-4 weeks ago. I have no idea about code, Linux, Apache, etc…, I just want to use the advanced capabilities of marketing automation that Mautic offers and walk away from Mailchimp. What version do you recommend? As for now, I don´t have problems if I need to change the version (doing a new installation).

Thaks in advance.

I believe it is @robert.luna2020 , I suggest you read the article I posted here before, but if you don’t have the time, it all boils down to your ability to sort out problems down the line and also about being able to get help when something breaks, and that hasn’t really changed that much.

The wrap up of that post is something like "If you already master Systems Administration, Mautic AND Cpanel, then go ahead.

Otherwise, take the harder route and learn these things in that order…