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
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.
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.
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?
@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.
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