Mautic Community Forums

Column not found: 1054 Unknown column '-' in 'generated column function' when upgrading from 3.0.2 to 3.1

Your software
My PHP version is : 7.2
My MySQL version is (delete as applicable): MySQL 8

Updating/Installing Errors
I am (delete as applicable): Updating
Upgrading/installing via (delete as applicable) : Web or Command Line

These errors are showing in the installer :

Constant page redirects

These errors are showing in the Mautic log :

[2020-08-30 06:10:25] console.ERROR: Error thrown while running command "doctrine:migrations:migrate --quiet --no-interaction". Message: "An exception occurred while executing 'ALTER TABLE email_stats ADD generated_sent_date DATE AS (CONCAT(YEAR(date_sent), "-", LPAD(MONTH(date_sent), 2, "0"), "-", LPAD(DAY(date_sent), 2, "0"))) COMMENT '(DC2Type:generated)';             ALTER TABLE email_stats ADD INDEX `generated_sent_date_email_id`(generated_sent_date, email_id)':  SQLSTATE[42S22]: Column not found: 1054 Unknown column '-' in 'generated column function'" {"exception":"[object] (Doctrine\\DBAL\\Exception\\InvalidFieldNameException(code: 0): An exception occurred while executing 'ALTER TABLE email_stats ADD generated_sent_date DATE AS (CONCAT(YEAR(date_sent), \"-\", LPAD(MONTH(date_sent), 2, \"0\"), \"-\", LPAD(DAY(date_sent), 2, \"0\"))) COMMENT '(DC2Type:generated)';\n            ALTER TABLE email_stats ADD INDEX `generated_sent_date_email_id`(generated_sent_date, email_id)':\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column '-' in 'generated column function' at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:60, Doctrine\\DBAL\\Driver\\PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column '-' in 'generated column function' at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:80, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column '-' in 'generated column function' at /var/www/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:75)","command":"doctrine:migrations:migrate --quiet --no-interaction","message":"An exception occurred while executing 'ALTER TABLE email_stats ADD generated_sent_date DATE AS (CONCAT(YEAR(date_sent), \"-\", LPAD(MONTH(date_sent), 2, \"0\"), \"-\", LPAD(DAY(date_sent), 2, \"0\"))) COMMENT '(DC2Type:generated)';\n            ALTER TABLE email_stats ADD INDEX `generated_sent_date_email_id`(generated_sent_date, email_id)':\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column '-' in 'generated column function'"} []

These errors are showing in the upgrade_log.txt file (located in the root of your Mautic instance when an upgrade has been attempted - ensure you remove or redact any sensitive data such as domain names in the file path) :

upgrade_log.txt does not exist.

Your problem
My problem is :

When running the upgrade from either the web interface or the command line, the upgrade fails during schema migration with the error above.

This results in the Mautic installation getting stuck in an infinite redirect loop in the browser and breaks the installation.

When running php bin/console mautic:update:apply, I am told to run it twice by the CLI, the second time with the --finish flag, and this is the point at which it fails.:

-bash-4.2$ /opt/remi/php72/root/bin/php bin/console mautic:update:find
Version 3.1.0 of Mautic is available for download. Please visit https://github.com/mautic/mautic/releases/tag/3.1.0 for more information.
To update, you can run 'php app/console mautic:update:apply' from the command line.
-bash-4.2$ /opt/remi/php72/root/bin/php bin/console mautic:update:apply
Are you sure you wish to update Mautic to the latest version? yes
Step    5 [----->----------------------] Clearing the cache

<warning>IMPORTANT: Run the same command again with --finish. For example 'php bin/console mautic:update:apply --finish'</warning>
-bash-4.2$ /opt/remi/php72/root/bin/php bin/console mautic:update:apply --finish
Step    2 [-->-------------------------] Migrating database schema...

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

Steps I have tried to fix the problem :

Tried installing from both the CLI and the web UI, to no avail

@MBConsultingUK is this issue related to the email builder issue?

Not as far as I’m aware, this is just from doing an upgrade.