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

| — | — | — | — |
route=/table/structure/change&change_column=1&field=properties&db=mauticdb&table=form_designer)|(DC2Type:json_array)

I will try this now,

I exported db from M4 and ran the sed command you suggested then imported the db into M5.

Here the result after I ran migration command

What did I do wrong or missed?

Thank you

agwm-mas@testcpserver:~/htdocs$ php bin/console doctrine:migrations:migrate --no-interaction
[2025-02-06 16:25:34]
[2025-02-06 16:25:34]
[2025-02-06 16:25:34]  [WARNING] You have 47 previously executed migrations in the database that are
[2025-02-06 16:25:34]            not registered migrations.
[2025-02-06 16:25:34]
[2025-02-06 16:25:34]
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:32 (20180508202930)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:32 (20180702014364)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:32 (20180702014365)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:33 (20180821144204)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:33 (20180921144421)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:33 (20181111095447)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:33 (20190704154940)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:33 (20190724110039)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:33 (20191017140848)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20191126093923)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20191206113956)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20191219155630)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20200211095409)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20200212141530)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20200220172041)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20200227110431)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20200302164801)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:34 (20200331160919)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200409102100)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200422144300)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200507122854)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200729170800)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200805185714)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200810153131)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200812180900)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:35 (20200815153711)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20200924080139)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201015084627)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201102120710)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201102133546)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201105120328)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201120122846)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201123070813)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201125155904)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201130201631)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201207114926)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201207140911)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20201228041109)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:36 (20210104171005)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20210203143600)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20210223174702)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20210502162314)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20210520100503)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20210609191822)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20210614151138)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20210623071326)
[2025-02-06 16:25:34]  >> 2022-03-16 22:54:37 (20220111202917)
[2025-02-06 16:25:34] [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.

the column type still “json_array” make sure you run properly

sed -i 's/\bjson_array\b/json/g' mautic_backup.sql

try to run migration /bin/console doctrine:migrations:migrate --no-interaction --dry-run

after that it may appear that some tables already exist, remove them from the DB and run the migration again then clear the cash.

I ran the following command on my Mac:

sed -i '.bak' 's/\bjson_array\b/json/g' mauticdb.sql

On macOS, the -i flag (for in-place editing) requires a backup file extension. That’s why I added .bak, which creates a backup of the original file before making changes.

Then imported it back into an empty database and ran the mirgation again where it seem to produce the same error again.

sed-ing is also fine.
I would try:

ALTER TABLE form_designer MODIFY COLUMN properties longtext COLLATE utf8mb4_unicode_ci COMMENT "DC2Type:json)";

agwm-mas@testcpserver:~/htdocs$ php bin/console doctrine:migrations:migrate --no-interaction --dry-run
[2025-02-06 16:42:09]
[2025-02-06 16:42:09]
[2025-02-06 16:42:09]  [WARNING] You have 47 previously executed migrations in the database that are
[2025-02-06 16:42:09]            not registered migrations.
[2025-02-06 16:42:09]
[2025-02-06 16:42:09]
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:32 (20180508202930)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:32 (20180702014364)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:32 (20180702014365)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:33 (20180821144204)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:33 (20180921144421)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:33 (20181111095447)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:33 (20190704154940)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:33 (20190724110039)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:33 (20191017140848)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20191126093923)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20191206113956)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20191219155630)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20200211095409)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20200212141530)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20200220172041)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20200227110431)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20200302164801)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:34 (20200331160919)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200409102100)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200422144300)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200507122854)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200729170800)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200805185714)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200810153131)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200812180900)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:35 (20200815153711)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20200924080139)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201015084627)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201102120710)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201102133546)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201105120328)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201120122846)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201123070813)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201125155904)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201130201631)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201207114926)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201207140911)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20201228041109)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:36 (20210104171005)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20210203143600)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20210223174702)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20210502162314)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20210520100503)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20210609191822)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20210614151138)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20210623071326)
[2025-02-06 16:42:09]  >> 2022-03-16 22:54:37 (20220111202917)
[2025-02-06 16:42:09] [notice] Migrating (dry-run) 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>]

agwm-mas@testcpserver:~/htdocs$

That seem to fix it.

So when I am ready to apply this on a production copy, I would need to delete all old plugs or at least upgrade it then do a dump / import and run ALTER TABLE and that should get my db upgraded to M5.

Thank you

Since it a separate issue so I decided to create a new topic on the statistic issue over at Do Mautic 4 statistics transfer to Mautic 5 after an upgrade?

Thanks for helping me getting the db migration issue resolved!