MySQL error upgrading to 4.2

Hi,

I had to play around with migrations to get it from Mautic 3 to 4 a bit too, because in previous versions of Mautic I have not executed update process completely, while I cannot remember the specific error I have a strong suspicion that your update error also comes from the same category of problems.

A general note on migrations in Mautic core: method isApplicable (or something very similar to that :)) is not really well implemented for all migrations thats why sometimes script ties to apply the migration even though you do not really need it.

About the error itself and how to work around it: A message from the log is saying that it cant renmae the index. You can triy to drop the index in question manually and then run the migration again. If that does not help see the steps below.

Upgrade process:

  • backup your mautic instance (source and database) as there is a possibility you will have to do the process multiple times
  • run php bin/console doctrine:migrations:migrate manually
  • migrations process will fail but while you run this command you can see exectly in which migration the problem is.
  • you now check the migration file of the failed migration, see what the migration is trying to do and adjust the database schema in a way so that migration can be applied (that usually means altering a table column)
  • after you manually update the schema just enough for the migration to apply schema changes successfully you run the doctrine migrations process again
  • this time it will either complete the migrations successfully or it will fail on the different migration, if it fails on different migration file you just inspect the failed migration fail again and repeat the process

Skipping migrations
After applying the process above you may come in a situation when during the process of manually updating the database schema for the migration you will actually update the schema in the same way as the migration file would if it would be applied successfully. When this happen you might want to skip the migration. You can do that by manually inserting a record in migrations table in your database.

Foreign keys
Some migrations might fail because of foreign key constraints, while FKs are important, you might encounter issues while trying to rescue the database, thats why you might want to turn off the foreign keys checks in the database before you start the migration, just remember to turn the checks back on when you are done.

I hope this helps, if you need further assistance let me know.

2 Likes