Upgrade from 4.4.13 to 5.2.6 cannot finish

Your software
My Mautic version is: 4.4.13
My PHP version is: PHP 8.1 (in order to support upgrade to 5.2.x - originally 7.4)
My Database type and version is: MariaDB 10.6

Your problem
I copied the instance to a separate installation in order to test the upgrade from 4.4.10 to latest 5.2. I did the upgrade to 4.4.13 (with PHP 7.4), all is well.

Running php bin/console mautic:update:apply --finish for the upgrade to 5.2.6 produced the following error in console

In AppKernelProdContainer.php line 11432:
                                                            
  The parameter "2BfyJlQzl1YYuwYO2ouVFYR" must be defined.  

These errors are showing in the log:
var/logs/prod-2025-06-13.php

[2025-06-13 07:37:38] mautic.WARNING: Command `mautic:update:apply` exited with status code 1  {"hostname":"yoshi-new","pid":118857}

Steps I have tried to fix the problem:
Searched everything, no luck :face_exhaling:

schema:validate command produced the following, while on 4.4.10, and schema:update --sql-dump produced a lot of queries


Mapping
-------

 [FAIL] The entity-class Mautic\DynamicContentBundle\Entity\DynamicContentLeadData mapping is invalid:
 * The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which is not defined as association.
 * The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which does not exist.


Database
--------

                                                                                                                        
 [ERROR] The database schema is not in sync with the current mapping file. 

I have experience in sysadmin stuff

This is a tricky one :slight_smile:
Hold on to you hat:
You cannot upgrade because of your email system password :slight_smile:

Your DSN (email config) has a string, which is not properly excaped. Try to remove it, upgrade and add it again :slight_smile:

You need to remove the email password anyway, since the email config is 100% new in Mautic 5.

So in my app/config/local.php, in all mailer_ settings, I put empty strings, NULL, or completely remove them? Or it doesn’t matter which option?

Ah it’s the mailer_dsn config, specifically and I removed it.

The update has moved, but produced another error! At least we’re getting there, step by step.

Database log

[ERROR] InnoDB: In ALTER TABLE `mautic`.`ma_emails` has or is referenced in foreign key constraints which are not compatible with the new table definition.

Database has a prefix ma_

I’ll get back on this. I was doing some weird stuff before, trying to fix the schema, so I’ll recreate and re-import the database so it’s clear

Any idea on this one?

I think it’s when this migration ran app/migrations/Version20201026101117.php, especially the $this->convertEmailsEmojies(); method in its postUp()

console.CRITICAL: Error thrown while running command "doctrine:migrations:migrate --quiet --no-interaction". Message: "An exception occurred while executing a query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'm0_.preheader_text' in 'SELECT'"
$ php bin/console mautic:update:apply --finish
Step    1 [>---------------------------] Migrating database schema...

An error occurred while updating the database. Check log for more details.

There are some migrations that are skipped, but still reported as “New” in doctrine:migration:status. Do I have to manually run them, see what’s the problem?

[notice] Migrating up to Mautic\Migrations\Versionzz20230929183000
[notice] Migration Mautic\Migrations\Version20201026101117 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Migration Mautic\Migrations\Version20221128145933 skipped during Pre-Checks. Reason: "Schema includes this migration"
[notice] Table ma_plugin_citrix_events already exists
[notice] Migration Mautic\Migrations\Version20230522141144 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] Migration Mautic\Migrations\Version20230627140512 skipped during Pre-Checks. Reason: "The deprecated %kernel.root_dir% is unused. Your local.php file is just fine. Skipping the migration."

I’m almost sure, that database prefixes will be ignored when migrations are applied. I had one client instance with a similar issue, where I removed the database prefix and this solved the issue.

@escopecz … in regards to migrations, do you know if database table prefixes will be respected?

That doesn’t respect the purpose of the database prefix though.. (Even I don’t know why we added it in our installation to be honest, but still)

Did you remove the prefix only from the config or from the tables too? (I’m guessing both)

@dirk_s yes, migrations also consider the table prefix. If there is a migration that does not then it is a bug. You can review all migrations in the app/migration folder and for example here you can see the tables are prefixed:

The idea of table prefixes were taken from the CMS Joomla! It allowed users to host multiple Mautic instances in 1 database to save costs. As that is a limitation of some web hostings. I don’t think it adds any value nowadays when web hostings aren’t recommended for Mautic anymore for various reasons. So I thing everyone is able to create multiple databases for each Mautic instance. It’d be great to drop the prefix one day and simplify the code.

1 Like

I agree on the prefix removal. Or at least let the sql driver handle it so when you run
$schema->getTable('xxx') and a prefix is configured, it would automatically get the ma_xxx table. I think this is how Drupal does it, when you use its Database API.

Moving on to more issues of the upgrade

For this topic scope, I only have the following yet to be answered

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.