Mautic 5 Migration Issue – Internal Server Error & Failed Database Migration

We are in the process of migrating and upgrading our Mautic instance from version 4 to 5 on a new host.

The old server was running MySQL, while the new server is using MariaDB.

We installed Composer and performed a fresh, clean installation of Mautic 5. Then, we emptied the Mautic 5 database and cache folder to prepare for importing the Mautic 4 database. After successfully importing the Mautic 4 database into Mautic 5, we attempted to run the Mautic migration process to update the database schema.

However, we encountered errors during the migration. Initially, we were able to log in using the Mautic 4 admin credentials, but the system crashed when attempting to access any application features in Mautic 5. After clearing the cache multiple times, we are now unable to log in at all, receiving an internal server error instead.

Below is the error message from the migration process.

Based on the steps we followed, this approach should have worked for migrating from Mautic 4 on the old server to Mautic 5, correct? The only major differences we noticed are the file path structure and the database switch from MySQL to MariaDB. Could that be causing the issue?

mas-ssh@testcpserver:~/htdocs$ /usr/bin/php8.1 bin/console doctrine:migrations:migrate --no-interaction
[2025-02-04 21:58:24]
[2025-02-04 21:58:24]
[2025-02-04 21:58:24]  [WARNING] You have 47 previously executed migrations in the database that are
[2025-02-04 21:58:24]            not registered migrations.
[2025-02-04 21:58:24]
[2025-02-04 21:58:24]
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:32 (20180508202930)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:32 (20180702014364)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:32 (20180702014365)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:33 (20180821144204)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:33 (20180921144421)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:33 (20181111095447)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:33 (20190704154940)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:33 (20190724110039)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:33 (20191017140848)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20191126093923)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20191206113956)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20191219155630)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20200211095409)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20200212141530)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20200220172041)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20200227110431)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20200302164801)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:34 (20200331160919)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200409102100)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200422144300)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200507122854)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200729170800)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200805185714)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200810153131)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200812180900)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:35 (20200815153711)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20200924080139)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201015084627)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201102120710)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201102133546)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201105120328)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201120122846)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201123070813)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201125155904)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201130201631)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201207114926)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201207140911)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20201228041109)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:36 (20210104171005)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20210203143600)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20210223174702)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20210502162314)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20210520100503)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20210609191822)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20210614151138)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20210623071326)
[2025-02-04 21:58:24]  >> 2022-03-16 22:54:37 (20220111202917)
[2025-02-04 21:58:24] [notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
[error] Migration Mautic\Migrations\Version20190326190241 failed during Pre-Checks. Error: "Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information."

In Exception.php line 115:

  Unknown column type "json_array" requested. Any Doctrine type that you use
  has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get
   a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(
  ). If this error occurs during database introspection then you might have f
  orgotten to register all database types for a Doctrine Type. Use AbstractPl
  atform#registerDoctrineTypeMapping() or have your custom types implement Ty
  pe#getMappedDatabaseTypes(). If the type name is empty you might have a pro
  blem with the cache or forgot some mapping information.


doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--all-or-nothing [ALL-OR-NOTHING]] [--no-all-or-nothing] [--configuration CONFIGURATION] [--em EM] [--conn CONN] [--] [<version>]

I see this in my error log. I am not sure but I believe that is a plugin maybe? I am checking further on this but wanted to update on this here.

[2025-02-04T22:03:35.823843+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 'l0_.is_index' in 'SELECT'")." at /home/agwm-mas/htdocs/docroot/app/bundles/CoreBundle/Resources/views/Modal/search_commands.html.twig line 46 {"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 'l0_.is_index' in 'SELECT'\"). at /home/agwm-mas/htdocs/docroot/app/bundles/CoreBundle/Resources/views/Modal/search_commands.html.twig:46)\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 'l0_.is_index' in 'SELECT' at /home/agwm-mas/htdocs/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 'l0_.is_index' in 'SELECT' at /home/agwm-mas/htdocs/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28)\n[previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'l0_.is_index' in 'SELECT' at /home/agwm-mas/htdocs/vendor/doctrine/dbal/src/Driver/PDO/Statement.php:130)"} {"hostname":"testcpserver","pid":153404}
[2025-02-04T22:03:37.659943+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 'l0_.is_index' in 'SELECT'")." at /home/agwm-mas/htdocs/docroot/app/bundles/CoreBundle/Resources/views/Modal/search_commands.html.twig line 46 {"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 'l0_.is_index' in 'SELECT'\"). at /home/agwm-mas/htdocs/docroot/app/bundles/CoreBundle/Resources/views/Modal/search_commands.html.twig:46)\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 'l0_.is_index' in 'SELECT' at /home/agwm-mas/htdocs/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 'l0_.is_index' in 'SELECT' at /home/agwm-mas/htdocs/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28)\n[previous exception] [object] (PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'l0_.is_index' in 'SELECT' at /home/agwm-mas/htdocs/vendor/doctrine/dbal/src/Driver/PDO/Statement.php:130)"} {"hostname":"testcpserver","pid":153404}

I installed the Twig plugin from the Mautic 4 and now I get a new error when trying to access Mautic page … This message show up (yes I did clear cache)

The “app/bundles/CoreBundle/Resources/views/Offline” directory does not exist (“//app/bundles/CoreBundle/Resources/views/Offline”).

I looked and the directory does exist and it’s there

agwm-mas@testcpserver:~/htdocs/docroot/app/bundles/CoreBundle/Resources/views/Offline$ ls
offline.html.twig

What am I missing?

I reran migrate again to see what it would do this time and here the error which is different from last time.

agwm-mas@testcpserver:~/htdocs$ php bin/console doctrine:migrations:migrate --no-interaction
PHP Fatal error:  Declaration of MauticPlugin\MauticTwigTemplatesBundle\Security\Permissions\TwigTemplatesPermissions::buildForm(Symfony\Component\Form\FormBuilderInterface &$builder, array $options, array $data) must be compatible with Mautic\CoreBundle\Security\Permissions\AbstractPermissions::buildForm(Symfony\Component\Form\FormBuilderInterface &$builder, array $options, array $data): void in /home/agwm-mas/htdocs/docroot/plugins/MauticTwigTemplatesBundle/Security/Permissions/TwigTemplatesPermissions.php on line 44
agwm-mas@testcpserver:~/htdocs$

Seems nobody isn’t able to help me with this yet so I am assuming it probably the plugins that causing my issue since it wouldn’t be compatible with Mautic 5 from 4.

I would have assume a good software would still upgrade successfully but disable plugin if it not compatible instead of preventing a upgrade or locking it up.

I haven’t tried removing plugins yet but plan to test that soon. I am still hoping there a way around to this issue without having to start tearing my Mautic 4 apart so I could just update it to 5.

Bill

Hello Bill!
Are yuo using the upgraded M5 version of the TwigTemplates Plugin?

We may not use Twig anymore in the new version since we hardly ever used it in 4. We want to be able to upgrade without having to use the plugins or needing to pay and upgrade plugins that we don’t use anymore.

Hello @techbill I faced the same issue can u check this repo it may help

:white_check_mark: Setting up Mautic in Docker
:white_check_mark: Exporting data from a live instance
:white_check_mark: Migrating the database to the new Dockerized version
:white_check_mark: Handling potential issues during migration

Just delete the plugin, delete cache, and try to clear cache again, and continue with the migrations.

Oh sorry, I can see you have the ‘json array’ issue.
Try this:

  1. Look for tables with the comment json_array
    Mysql:
    SELECT table_schema, table_name, column_name, column_comment FROM information_schema.columns WHERE column_comment LIKE ‘%(DC2Type:json_array)%’;

  2. Change them:
    ALTER TABLE custom_field MODIFY COLUMN params longtext COLLATE utf8mb4_unicode_ci COMMENT ‘(DC2Type:json)’;

(use the right columns)

Actually, I think I managed to fix that json array issue.

It a different issue now. I delete the outdated plugins and now I am getting this when trying to migrate so I am still investigating.

In DefinitionErrorExceptionPass.php line 49:

Cannot autowire service “MauticPlugin\MauticAdvancedTemplatesBundle\Feed\Fe
ed”: argument “$feed” of method “__construct()” has no type-hint, you shoul
d configure its value explicitly.

Cool. I will check it out.

Thanks

I get this when trying to SELECT

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘:json_array)%’ LIMIT 0, 25’ at line 1

SELECT table_schema, table_name, column_name, column_comment FROM information_schema.columns WHERE column_comment LIKE ‘%(DC2Type:json_array)%

without the ’

If you have ‘leftovers’ from old plugins you deleted, you can always really clear the cache:
rm -rf /var/www/html/mautic/var/cache/prod/*

(Adjust your path)

Ok I deleted some more plugins and deleted the cache folder.

Now that json error is back again

agwm-mas@testcpserver:~/htdocs$ php bin/console doctrine:migrations:migrate --no-interaction
[2025-02-06 15:38:47]
[2025-02-06 15:38:47]
[2025-02-06 15:38:47]  [WARNING] You have 47 previously executed migrations in the database that are
[2025-02-06 15:38:47]            not registered migrations.
[2025-02-06 15:38:47]
[2025-02-06 15:38:47]
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:32 (20180508202930)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:32 (20180702014364)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:32 (20180702014365)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:33 (20180821144204)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:33 (20180921144421)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:33 (20181111095447)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:33 (20190704154940)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:33 (20190724110039)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:33 (20191017140848)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20191126093923)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20191206113956)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20191219155630)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20200211095409)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20200212141530)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20200220172041)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20200227110431)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20200302164801)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:34 (20200331160919)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200409102100)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200422144300)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200507122854)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200729170800)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200805185714)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200810153131)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200812180900)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:35 (20200815153711)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20200924080139)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201015084627)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201102120710)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201102133546)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201105120328)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201120122846)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201123070813)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201125155904)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201130201631)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201207114926)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201207140911)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20201228041109)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:36 (20210104171005)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20210203143600)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20210223174702)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20210502162314)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20210520100503)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20210609191822)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20210614151138)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20210623071326)
[2025-02-06 15:38:47]  >> 2022-03-16 22:54:37 (20220111202917)
[2025-02-06 15:38:47] [notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
[error] Migration Mautic\Migrations\Version20190326190241 failed during Pre-Checks. Error: "Unknown column type "json_array" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspection then you might have forgotten to register all database types for a Doctrine Type. Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you might have a problem with the cache or forgot some mapping information."

In Exception.php line 115:

  Unknown column type "json_array" requested. Any Doctrine type that you use
  has to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get
   a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(
  ). If this error occurs during database introspection then you might have f
  orgotten to register all database types for a Doctrine Type. Use AbstractPl
  atform#registerDoctrineTypeMapping() or have your custom types implement Ty
  pe#getMappedDatabaseTypes(). If the type name is empty you might have a pro
  blem with the cache or forgot some mapping information.

Whenever I make any changes in Mautic, I just do a rm -rf cache and delete the whole cache folder. Now I have this json error again and I tried your suggestion to select and alter but I am getting an error trying to select.

Do you have prefix for your tables?

Try this:

SELECT table_schema, table_name, column_name, column_comment FROM information_schema.columns WHERE column_comment LIKE "%(DC2Type:json_array)%";

make a dump of your database, Mautic uses Symfony and Doctrine updates, which may have changed the way JSON fields are handled. If Mautic previously used json_array and the new version expects json, this fix ensures compatibility.

sed -i 's/\bjson_array\b/json/g' mautic_backup.sql
re import it and run the migration again then clear the cache