Mautic 6.0.0 to 6.0.2 Update Can't DROP INDEX `mtc_company_match` Error

I originally downloaded the Mautic 6.0.0 zip from the Mautic GitHub release page and successfully installed it manually without using composer. Mautic 6.0.0 was working.

To upgrade to Mautic 6.0.2 I have run the following commands as documented.

php bin/console mautic:update:find

It identified that I was running Mautic 6.0.0 and there was an update available to Mautic 6.0.2.

I then applied the update with:
php bin/console mautic:update:apply

However when I run the next command it failed with the following errors
php bin/console mautic:update:apply --finish

In ExceptionConverter.php line 117:
An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP INDEX mtc_company_match; check that it exists

In Exception.php line 28:
SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP INDEX mtc_company_match; check that it exists
In Connection.php line 71:
SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP INDEX mtc_company_match; check that it exists

When I run the following: I get some info on the database migration status.
php bin/console doctrine:migration:status

Versions | Previous | Mautic\Migrations\Version20210112162046 |
| | Current | Mautic\Migrations\Version20210211081531 |
| | Next | Mautic\Migrations\Version20190326190241 |
| | Latest | Mautic\Migrations\Versionzz20230929183000 |
|----------------------------------------------------------------------------------------------------------------------|
| Migrations | Executed | 5 |
| | Executed Unavailable | 0 |
| | Available | 63 |
| | New | 58

The above states that Mautic\Migrations\Versionzz20230929183000 is the latest ?

However in theapps/migrations directory there is :
Version20250207035735.php and Versionzz20230929183000.php at the end of the list

The 2023 version is last in the list because zz is appended to the end of the word version i.e. Versionzz20230929183000. And as such will always be the last file in the list.

Can a developer please confirm that I’m my case the wrong php file version is being used for the database migration causing the “Can’t DROP INDEX `mtc_company_match’” error as defined above ?

Please note that Versionzz20230929183000.php is distributed in the Mautic 6.0.0 zip

Has anyone successfully used this technique upgrading Mautic from 6.0.0 to 6.0.2 ?

Thanks.

Hello,

I have checked the mtc_migrations table and when I attempted to upgrade from Mautic 6.0.0 to 6.0.2, according to the database it recorded a number of data migrations ?

Surely when Mautic 6.0.0 was installed it had the latest database schema ? Why would the upgrade run older migrations and not the 2025 one ?

Is this by design or is there a bug in database migrations ?

Thanks.

Hello,

Migration 6.0.0 to 6.0.2
I restored my database and the files in public_html back to pre migration.
I then ran the migration again using the same procedure.
Same error as above.

Migration 6.0.1 to 6.0.2
I spun up a test instance of 6.0.1 and populated it with some test data.
I then ran the migration procedure on this test instance.
Same error as above.

In both cases index mtc_company_match exists in the database so either the code can’t drop the index or possibly our web platform or database is unable to drop the index. Or the code is wrongly trying to drop the index. Only the developers can confirm what should happen.

I have to conclude that the migration leaves the database in an unknown state as it doesn’t complete cleanly. And there is no way to manually check what changes have been made.

May be the developers should consider documenting the database changes separately outside of the code so that if the database does suffer a problem any database administrator can easily resolve the database problems manually. This is how all commercial software is developed and all good open source projects as well.

WARNING - If you are running 6.0.0, backup your database and files before trying to update to the latest edition and try it on a test instance before running it on a production system. I’ve been unable to get it to work on either so far.

I believe a version upgrade that fails leaving the database in an unknown state is a critical problem but so far no developer has responded to my posts which is disappointing.

I hope the developers look at this problem and come up with a quick fix asap. I’m trying to quickly install the security fixes in 6.0.2 and have spent man days trying to get version upgrades working which should work by default.

Thanks.

Hello,

I have spun up a Mautic 6.0.2 test instance that has no added data i.e. a default new install database.

When I run the following command to determine outstanding migrations it thinks there are 63 which is a shock on a new install.
php bin/console doctrine:migration:status

The commands and procedures were taken from the the following documentation

Will you please investigate and resolve these database migration inconsistencies on Mautic 6.x as a matter of urgency.

Thanks.

You are not alone.
Have the same problem.
Anyone can help?

I am having a similar issue, in that my new (from scratch, using Composer) installation of 6.0.1 likewise lists 63 new migrations, including the one with the zz suffix from 2023.

I managed to kill a 5.2.5 installation through upgrading, and was expecting a fresh installation to be “migration-free”…

bin/console mautic:update:apply --finish results in:
Step 2 [============================] Success! You are now running version 6.0.2 of Mautic.

But then bin/console doctrine:migration:migrate --no-interaction
results in:
[OK] Successfully migrated to version: Mautic\Migrations\Versionzz20230929183000

gives (the same errors I was having with 5.2.5):

[WARNING] Not passing the “–complete” option to “doctrine:schema:update” is deprecated and will not be supported when using doctrine/dbal 4

Updating database schema…

In ExceptionConverter.php line 117:

An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP INDEX IDX_1AE3441319EB6921; check that it exists

In Exception.php line 28:

SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP INDEX IDX_1AE3441319EB6921; check that it exists

In Connection.php line 33:

SQLSTATE[42000]: Syntax error or access violation: 1091 Can’t DROP INDEX IDX_1AE3441319EB6921; check that it exists
doctrine:schema:update [–em EM] [–complete] [–dump-sql] [-f|–force]
bin/console doctrine:schema:update --no-interaction --force

I believe the issue lies with unnecessary migrations being applied, but I don’t know enough to track it down exactly.