Mautic Community Forums

Can't add additional custom fields --- Alter Table Error

Your software
My Mautic version is: v4.1.1
My PHP version is: PHP Version 7.4.27
My Database type and version is:

Version:
10.3.29-MariaDB-cll-lve
Doctrine driver
pdo_mysql

                            Doctrine database platform (automatically detected)
                            	Doctrine\DBAL\Platforms\MariaDb1027Platform
    • Linux az1-ts4.a2hosting.com 3.10.0-962.3.2.lve1.5.52.el7.x86_64 #1 SMP Tue Apr 13 05:36:43 EDT 2021 x86_64

Your problem
My problem is:
When I try to add additional custom fields I get the following error and are not able to add addition custom fields.

An exception occurred while executing ‘ALTER TABLE maup6_leads ADD class_device VARCHAR(255) DEFAULT NULL’: SQLSTATE[42S22]:
** Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’**

These errors are showing in the log:

–Log
Database info

Current Error Log

[2022-01-14 19:17:47] mautic.NOTICE: PHP Notice - Undefined offset: 1 - in file /home/danianim/public_html/mautic/app/bundles/LeadBundle/Views/Auditlog/details.html.php - at line 62 {“mauticTemplateVars”:{“app”:"[object] (Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables: {})",“event”:{“eventType”:“update”,“eventLabel”:“System”,“timestamp”:“2021-10-02 11:45:04”,“details”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“contentTemplate”:“MauticLeadBundle:Auditlog:details.html.php”},“lead”:"[object] (Mautic\LeadBundle\Entity\Lead: Mautic\LeadBundle\Entity\Lead with ID #23646)",“mauticContent”:“lead”,“mauticTemplate”:“MauticLeadBundle:Auditlog:details.html.php”,“view”:"[object] (Mautic\CoreBundle\Templating\Engine\PhpEngine: {})"},“app”:"[object] (Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables: {})",“event”:{“eventType”:“update”,“eventLabel”:“System”,“timestamp”:“2021-10-02 11:45:04”,“details”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“contentTemplate”:“MauticLeadBundle:Auditlog:details.html.php”},“lead”:"[object] (Mautic\LeadBundle\Entity\Lead: Mautic\LeadBundle\Entity\Lead with ID #23646)",“mauticContent”:“lead”,“mauticTemplate”:“MauticLeadBundle:Auditlog:details.html.php”,“view”:"[object] (Mautic\CoreBundle\Templating\Engine\PhpEngine: {})",“details”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“type”:“update”,“text”:"",“objects”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“value”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]},“key”:“tags”,“values”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]},“field”:“tags”} [2022-01-14 19:17:47] mautic.NOTICE: PHP Notice - Undefined offset: 0 - in file /home/danianim/public_html/mautic/app/bundles/LeadBundle/Views/Auditlog/details.html.php - at line 62 {“mauticTemplateVars”:{“app”:"[object] (Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables: {})",“event”:{“eventType”:“update”,“eventLabel”:“System”,“timestamp”:“2021-10-02 11:45:04”,“details”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“contentTemplate”:“MauticLeadBundle:Auditlog:details.html.php”},“lead”:"[object] (Mautic\LeadBundle\Entity\Lead: Mautic\LeadBundle\Entity\Lead with ID #23646)",“mauticContent”:“lead”,“mauticTemplate”:“MauticLeadBundle:Auditlog:details.html.php”,“view”:"[object] (Mautic\CoreBundle\Templating\Engine\PhpEngine: {})"},“app”:"[object] (Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables: {})",“event”:{“eventType”:“update”,“eventLabel”:“System”,“timestamp”:“2021-10-02 11:45:04”,“details”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“contentTemplate”:“MauticLeadBundle:Auditlog:details.html.php”},“lead”:"[object] (Mautic\LeadBundle\Entity\Lead: Mautic\LeadBundle\Entity\Lead with ID #23646)",“mauticContent”:“lead”,“mauticTemplate”:“MauticLeadBundle:Auditlog:details.html.php”,“view”:"[object] (Mautic\CoreBundle\Templating\Engine\PhpEngine: {})",“details”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“type”:“update”,“text”:"

Field/Object New Value Old Value

“,“objects”:{“tags”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]}},“value”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]},“key”:“tags”,“values”:{“added”:[“FC Re Invited - Missed Class”],“removed”:[“FC Missed”]},“field”:“tags”} [2022-01-14 20:45:39] mautic.WARNING: An exception occurred while executing ‘ALTER TABLE maup6_leads ADD class_device VARCHAR(255) DEFAULT NULL’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ [2022-01-14 20:46:28] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: “An exception occurred while executing ‘ALTER TABLE maup6_leads DROP foursquare’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’” at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 79 {“exception”:”[object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing ‘ALTER TABLE maup6_leads DROP foursquare’:\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:79, Doctrine\DBAL\Driver\PDO\Exception(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:53)"} [2022-01-14 20:47:12] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: “An exception occurred while executing ‘ALTER TABLE maup6_leads DROP honeypot’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’” at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 79 {“exception”:"[object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing ‘ALTER TABLE maup6_leads DROP honeypot’:\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:79, Doctrine\DBAL\Driver\PDO\Exception(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:53)"} [2022-01-14 20:47:42] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: “An exception occurred while executing ‘ALTER TABLE maup6_leads DROP counter’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’” at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 79 {“exception”:"[object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing ‘ALTER TABLE maup6_leads DROP counter’:\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:79, Doctrine\DBAL\Driver\PDO\Exception(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:53)"} [2022-01-14 20:49:44] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: “Argument 1 passed to Mautic\LeadBundle\Model\FieldModel::getFieldSegments() must be an instance of Mautic\LeadBundle\Entity\LeadField, null given, called in /home/danianim/public_html/mautic/app/bundles/LeadBundle/Controller/FieldController.php on line 427” at /home/danianim/public_html/mautic/app/bundles/LeadBundle/Model/FieldModel.php line 694 {“exception”:"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Argument 1 passed to Mautic\LeadBundle\Model\FieldModel::getFieldSegments() must be an instance of Mautic\LeadBundle\Entity\LeadField, null given, called in /home/danianim/public_html/mautic/app/bundles/LeadBundle/Controller/FieldController.php on line 427 at /home/danianim/public_html/mautic/app/bundles/LeadBundle/Model/FieldModel.php:694)"} [2022-01-14 20:50:26] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\InvalidFieldNameException: “An exception occurred while executing ‘ALTER TABLE maup6_leads DROP googleplus’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’” at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 79 {“exception”:"[object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 0): An exception occurred while executing ‘ALTER TABLE maup6_leads DROP googleplus’:\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:79, Doctrine\DBAL\Driver\PDO\Exception(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ at /home/danianim/public_html/mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:53)"} [2022-01-14 20:52:51] mautic.WARNING: An exception occurred while executing ‘ALTER TABLE maup6_leads ADD class_device VARCHAR(255) DEFAULT NULL’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ [2022-01-14 20:53:59] mautic.WARNING: An exception occurred while executing ‘ALTER TABLE maup6_leads ADD class_device VARCHAR(255) DEFAULT NULL’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ [2022-01-14 20:54:47] mautic.WARNING: An exception occurred while executing ‘ALTER TABLE maup6_leads ADD class_device VARCHAR(255) DEFAULT NULL’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’ [2022-01-15 08:21:24] mautic.WARNING: An exception occurred while executing ‘ALTER TABLE maup6_leads ADD class_device VARCHAR(255) DEFAULT NULL’: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘danianim_maut458.l.email’ in ‘GENERATED ALWAYS’

Steps I have tried to fix the problem:

  1. Run the database repair script from here: Troubleshooting | Mautic

Try to fix the database schema

Go to http://[your-mautic-url]/s/update/schema

  1. Review the database schema
  2. Remove a couple of unused custom fields to ensure that there is table space to add a field.