Your software
My Mautic version is: 5.2.0
My PHP version is: 8.2.x
My Database type and version is: mariadb
Your problem
My problem is:
After an upgrade the database migrate did not run 100% - so when accessing the emails to create or edit we get this issue below in the logs
error 500
These errors are showing in the log:
[2024-12-03T16:58:45.485023+00:00] mautic.CRITICAL: Uncaught PHP Exception Twig\Error\RuntimeError: “An exception has been thrown during the rendering of a template (“An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘t0.draft_custom_mjml’ in ‘SELECT’”).” at /home/mautic/webapps/gomautic/public/app/bundles/EmailBundle/Resources/views/Email/form.html.twig line 77 {“exception”:“[object] (Twig\Error\RuntimeError(code: 0): An exception has been thrown during the rendering of a template ("An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘t0.draft_custom_mjml’ in ‘SELECT’"). at /home/mautic/webapps/gomautic/public/app/bundles/EmailBundle/Resources/views/Email/form.html.twig:77)\n[previous exception] [object] (Doctrine\DBAL\Exception\InvalidFieldNameException(code: 1054): An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘t0.draft_custom_mjml’ in ‘SELECT’ at /home/mautic/webapps/gomautic/public/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:67)\n[previous exception] [object] (Doctrine\DBAL\Driver\PDO\Exception(code: 1054): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘t0.draft_custom_mjml’ in ‘SELECT’ at /home/mautic/webapps/gomautic/public/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28)\n[previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘t0.draft_custom_mjml’ in ‘SELECT’ at /home/mautic/webapps/gomautic/public/vendor/doctrine/dbal/src/Driver/PDO/Statement.php:130)”} {“hostname”:“XXXXXX”,“pid”:3419938}
Steps I have tried to fix the problem:
Cannot find anything online relating to this issue.
Hi there!
It looks like you haven’t run your database migrations hence you have a missing column, because it’s required for the email drafts feature.
Please go back and run those, then it should create the column which is missing, as stated in the error.
- Back up your database and test that it’s a good backup
- Run the command
bin/console doctrine:migration:migrate
(you might need to precede it with php
, depending on your configuration) to kick off the migrations
If that throws an error then let us know.
I just ran this, and it returned the following…
[notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
[notice] Migration Mautic\Migrations\Version20190326190241 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20190410143658 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Schema includes this migration
[notice] Migration Mautic\Migrations\Version20190524124819 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20200415135706 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20200513162918 skipped during Pre-Checks. Reason: "The body_text column has already been added to the gom2411email_copies table."
[notice] Migration Mautic\Migrations\Version20200917152259 skipped during Pre-Checks. Reason: "default_value is already the correct type."
[notice] Migration Mautic\Migrations\Version20201019100000 skipped during Pre-Checks. Reason: "Table gom2411emails_draft already exists. Skipping migration"
[notice] Migration Mautic\Migrations\Version20201026101117 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20210112162046 skipped during Pre-Checks. Reason: "Index `integration_integration_object_name_last_sync_date` already exists. Skipping the migration"
[notice] Migration Mautic\Migrations\Version20210115065034 skipped during Pre-Checks. Reason: "The emails table already includes the preheader_text column"
[notice] Migration Mautic\Migrations\Version20210217115150 skipped during Pre-Checks. Reason: "Deleted column already added in tables"
[notice] Index gom2411lead_list_alias already exists
[notice] Migration Mautic\Migrations\Version20210420113309 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Index gom2411idx_object_field_order_is_published already exists
[notice] Migration Mautic\Migrations\Version20211026152443 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Index gom2411idx_frequency_date_added already exists
[notice] Migration Mautic\Migrations\Version20211026153057 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Column already in BOOLEAN type
[notice] Migration Mautic\Migrations\Version20211110070503 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Table gom2411contact_export_scheduler already exists
[notice] Migration Mautic\Migrations\Version20220429091934 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20220722074516 skipped during Pre-Checks. Reason: "The deduplicate column has already been added to the gom2411notifications table."
[notice] Migration Mautic\Migrations\Version20221014061125 skipped during Pre-Checks. Reason: "Index gom2411webhook_id_date_added already exists"
[notice] Migration Mautic\Migrations\Version20221014081742 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20221128145933 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20230131133732 skipped during Pre-Checks. Reason: "The last_built_time column has already been added to the gom2411lead_lists table."
[notice] Column gom2411asset_downloads.utm_campaign already exists
[notice] Column gom2411asset_downloads.utm_content already exists
[notice] Column gom2411asset_downloads.utm_medium already exists
[notice] Column gom2411asset_downloads.utm_source already exists
[notice] Column gom2411asset_downloads.utm_term already exists
[notice] Migration Mautic\Migrations\Version20230321133733 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20230424083829 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "gom2411dnc_date_added" has already been added to the table "gom2411lead_donotcontact".
[notice] Migration Mautic\Migrations\Version20230506112314 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "gom2411stat_dynamic_content_date_sent" has already been added to the table "gom2411dynamic_content_stats".
[notice] Migration Mautic\Migrations\Version20230506113422 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "gom2411message_queue_date_published" has already been added to the table "gom2411message_queue".
[notice] Migration Mautic\Migrations\Version20230506113627 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "gom2411lead_stages_change_log_date_added" has already been added to the table "gom2411lead_stages_change_log".
[notice] Migration Mautic\Migrations\Version20230506113731 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] The index "gom2411utm_date_added" has already been added to the table "gom2411lead_utmtags".
[notice] Migration Mautic\Migrations\Version20230506113812 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Table gom2411plugin_crm_pipedrive_owners was already removed
[notice] Migration Mautic\Migrations\Version20230519154448 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration is not required.
[notice] Migration Mautic\Migrations\Version20230606111852 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Table gom2411point_groups already exists
[notice] Table gom2411point_group_contact_score already exists
[notice] Column gom2411points.group_id already exists
[notice] Column gom2411point_triggers.group_id already exists
[notice] Column gom2411lead_points_change_log.group_id already exists
[error] Migration Mautic\Migrations\Version20230621074925 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'gom2411point_groups' already exists"
In ExceptionConverter.php line 45:
An exception occurred while executing a query: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'gom2411point_groups' already exists
In Exception.php line 28:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'gom2411point_groups' already exists
In Connection.php line 71:
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'gom2411point_groups' already exists
Great, then this problem pre-dates your current update, and thankfully we’ve had folks reporting that problem on the forums before, eg How to update 5 to 5.0.1 via composer? - #7 by escopecz.
Give that a shot (of course, making sure you have a good database backup) to see if that fixes the pre-existing issue with migrations.
I tested the email draft feature before the PR was merged and it worked. I also double-checked that the migration and don’t see any issue.
Try to run just the single migration:
bin/console doctrine:migrations:execute --up "Mautic\\Migrations\\Version20240611103824"
@escopecz I can confirm the update using the execution you provided worked.
I am stumped though as to why this did not work when the upgrade took place.
Any reason ?
M.
Just a thought, it would be great if these migration files had a different naming convention that actually made sense to the specific version it applies to… And somehow in a list order which makes sense. So that when you are looking for one which applies, you can quickly find this.
@rcheesley @escopecz
Just a thought.