Your software
My Mautic version is: 4.2.1
My PHP version is: 7.4
My Database type and version is: mariadb 10.04
Your problem
My problem is:
When trying to add a new custom field I am getting an error
These errors are showing in the log:
An exception occurred while executing 'ALTER TABLE leads ADD new_field_name DATE DEFAULT NULL': SQLSTATE[42S22]: Column not found: 1054 Unknown column '`mautic`.`l`.`email`' in 'GENERATED ALWAYS'
Steps I have tried to fix the problem:
Researched the forum
Researched Google
Reaching out to someone who understands DB to help here.
I think that the culprit of all these bad database issues is the generated_email_domain column that I have not idea who puts in there or who is using it, but I went and dropped this table, then I was able to add more custom fields and also drop other unwanted columns inside the mautic database.
@rcheesley - any idea what this column is, who is creating it and why ? and what happens if I drop it ?
My main question is what is this needed for and how badly will things going wrong if I drop this column ?
I have done it in a test environment and everything seems to be working.
If you can point me to the correct place I am happy to open an issue on GitHub.
Are you able to access your MySQL database ? If so I would suggest following my directions above - alter table leads drop column generated_email_domains (or something like that, not in front of computer).
After I did this everything continued working and I was able to create new custom fields.
By the way I would strongly suggest doing a dump of your database before doing this.
Mysqldump -u username database_name -pPassword | gzip > Mautic-db-backup-date.sql.gz
I donât think it will break anything if you remove that column but I suggest to leave it there. It will be created again when you run migrations during next Mautic upgrade.
The generated field basically takes the email address of the contact in the âemailâ column and takes the domain name after the â@â. Then you can use that value in segment filters which is much faster than other methods. Itâs MySql feature so Mautic does not have to care about keeping this field up to date. MySql does it for us.
Can you please confirm that you have the âemailâ column in the âleadsâ table? The error suggests that that column is missing.
I will try and get an instance up with the problem prevalent as I had already gone ahead and deleted these fields and run the commands you suggested and document results here.
after using the above mentioned solution and using mautic afterwards I can say, that the solution is only temporarily. After a while I had to do âthe solutionâ again.
Either a cron job does some changes or the mautic app code itself has some âhealingâ functionality.
After deleting the column. I was able to add custom field so I again added the deleted column by running ALTER TABLE leads ADD COLUMN generated_email_domain VARCHAR(255) AFTER fieldname; and it worked for me. Now I donât need to delete column again to add custom fields.