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

**URL:** <https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869>\
**Category:** Mautic 3 - Install/Upgrade Support\
**Created:** [August 30, 2020, 6:19am UTC](https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869 "2020-08-30T06:19:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MBConsultingUK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mbconsultinguk/32/1255_2.png) [@MBConsultingUK](https://forum.mautic.org/u/MBConsultingUK)\
**Post date:** [August 30, 2020, 6:19am UTC](https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869/1 "2020-08-30T06:19:07Z")

</div>

**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_ :

```auto
[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.:

```auto
-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

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [September 10, 2020, 11:36am UTC](https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869/2 "2020-09-10T11:36:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MBConsultingUK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mbconsultinguk/32/1255_2.png) [@MBConsultingUK](https://forum.mautic.org/u/MBConsultingUK)\
**Post date:** [September 10, 2020, 1:57pm UTC](https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869/3 "2020-09-10T13:57:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RdJong](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/rdjong/32/703_2.png) [@RdJong](https://forum.mautic.org/u/RdJong)\
**Post date:** [November 9, 2020, 7:13pm UTC](https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869/4 "2020-11-09T19:13:10Z")

</div>

Sorry for this late reaction on this topic, but I just wanted to install Mautic 3.1.2 and got the same error.  
What can I do to fix this?

 ![Screenshot 2020-11-09 at 20.12.01](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/e/ed22370db418f281234b9d98e8bea4527e7bab20.png)

---

<div class="post-metadata">

**Author:** ![MarcoCianci](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/marcocianci/32/4330_2.png) [@MarcoCianci](https://forum.mautic.org/u/MarcoCianci)\
**Post date:** [January 20, 2021, 8:20pm UTC](https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869/5 "2021-01-20T20:20:10Z")

</div>

@MBConsultingUK

the problem are here:

```
generated_sent_date DATE AS (CONCAT(YEAR(date_sent), "-", LPAD(MONTH(date_sent), 2, "0"), "-", LPAD(DAY(date_sent), 2, "0"))) COMMENT '(DC2Type:generated)', 

```

fix quotes, from double quotes (") to simple quotes (')

```
generated_sent_date DATE AS (CONCAT(YEAR(date_sent), '-', LPAD(MONTH(date_sent), 2, '0'), '-', LPAD(DAY(date_sent), 2, '0'))) COMMENT '(DC2Type:generated)', 

```

You can create table with this code:

> CREATE TABLE email\_stats (  
> id BIGINT UNSIGNED AUTO\_INCREMENT NOT NULL,  
> email\_id INT UNSIGNED DEFAULT NULL,  
> lead\_id BIGINT UNSIGNED DEFAULT NULL,  
> list\_id INT UNSIGNED DEFAULT NULL,  
> ip\_id INT UNSIGNED DEFAULT NULL,  
> copy\_id VARCHAR(32) DEFAULT NULL,  
> email\_address VARCHAR(191) NOT NULL,  
> date\_sent DATETIME NOT NULL,  
> is\_read TINYINT(1) NOT NULL,  
> is\_failed TINYINT(1) NOT NULL,  
> viewed\_in\_browser TINYINT(1) NOT NULL,  
> date\_read DATETIME DEFAULT NULL,  
> tracking\_hash VARCHAR(191) DEFAULT NULL,  
> retry\_count INT DEFAULT NULL,  
> `source` VARCHAR(191) DEFAULT NULL,  
> source\_id INT DEFAULT NULL,  
> tokens LONGTEXT DEFAULT NULL COMMENT ‘(DC2Type:array)’,  
> open\_count INT DEFAULT NULL,  
> last\_opened DATETIME DEFAULT NULL,  
> open\_details LONGTEXT DEFAULT NULL COMMENT ‘(DC2Type:array)’,  
> generated\_sent\_date DATE AS (  
> CONCAT(  
> YEAR(date\_sent),  
> ‘-’,  
> LPAD(MONTH(date\_sent), 2, ‘0’),  
> ‘-’,  
> LPAD(DAY(date\_sent), 2, ‘0’)  
> )  
> ) COMMENT ‘(DC2Type:generated)’,  
> INDEX IDX\_CA0A2625A832C1C9 (email\_id), INDEX IDX\_CA0A262555458D (lead\_id), INDEX IDX\_CA0A26253DAE168B (list\_id),  
> INDEX IDX\_CA0A2625A03F5E9F (ip\_id), INDEX IDX\_CA0A2625A8752772 (copy\_id), INDEX stat\_email\_search (email\_id, lead\_id),  
> INDEX stat\_email\_search2 (lead\_id, email\_id), INDEX stat\_email\_failed\_search (is\_failed), INDEX is\_read\_date\_sent (is\_read, date\_sent),  
> INDEX stat\_email\_hash\_search (tracking\_hash), INDEX stat\_email\_source\_search (source, source\_id), INDEX email\_date\_sent (date\_sent),  
> INDEX email\_date\_read\_lead (date\_read, lead\_id),  
> INDEX generated\_sent\_date\_email\_id (generated\_sent\_date, email\_id),  
> PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW\_FORMAT = DYNAMIC  
> ;

or in file

> Blockquote ./app/bundles/EmailBundle/EventListener/GeneratedColumnSubscriber.php

you can find this file and problem using this command at ssh

```
find ./ -type f -exec grep -H 'generated_sent_date' {} \;

```

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [January 21, 2021, 1:38pm UTC](https://forum.mautic.org/t/column-not-found-1054-unknown-column-in-generated-column-function-when-upgrading-from-3-0-2-to-3-1/15869/6 "2021-01-21T13:38:09Z")

</div>

Linking to Github issue:

> <https://github.com/mautic/mautic/issues/9388#issuecomment-764647214>
>
> Bug Description
> I just wanted to install Mautic 3.1.2 on my Linux server with PHP 7.3 and MySQL 8.0.20, but the installation...
