Updating from 4.1.0 from 4.2.1 blew my mautic up

Your software
My PHP version is : 7.4
My MySQL/MariaDB version is (delete as applicable): MySQL v8.0

Updating/Installing Errors
I am Updating
Upgrading/installing via Web at first (didn’t work, never does), now I am learning CLI.

These errors are showing in the installer : I cannot get the web UI to load anymore. After running: <php bin/console doctrine:schema:update --force> I get this:

In AbstractMySQLDriver.php line 128:
An exception occurred while executing ‘ALTER TABLE oauth2_accesstokens CHANGE client_id client_id INT UN
SIGNED NOT NULL, CHANGE user_id user_id INT UNSIGNED DEFAULT NULL, CHANGE token token VARCHAR(191) NOT N
ULL, CHANGE scope scope VARCHAR(191) DEFAULT NULL’:

SQLSTATE[HY000]: General error: 3780 Referencing column ‘user_id’ and referenced column ‘id’ in foreign
key constraint ‘FK_3A18CA5AA76ED395’ are incompatible.

In Exception.php line 18:
SQLSTATE[HY000]: General error: 3780 Referencing column ‘user_id’ and referenced column ‘id’ in foreign
key constraint ‘FK_3A18CA5AA76ED395’ are incompatible.

In PDOConnection.php line 132:
SQLSTATE[HY000]: General error: 3780 Referencing column ‘user_id’ and referenced column ‘id’ in foreign
key constraint ‘FK_3A18CA5AA76ED395’ are incompatible.

These errors are showing in the Mautic log :
I cannot access Mautic anymore.

Executed Migrations: 181
Executed Unavailable Migrations: 134
Available Migrations: 47
New Migrations: 0

Your problem
My problem is :
I cannot access the Mautic web UI at all.

Steps I have tried to fix the problem :
I have tried all these tips: https://docs.mautic.org/en/troubleshooting and these: https://mauteam.org/mautic/mautic-admins/mautic-update-how-to-dont-click-that-button/

I have tried to revert back to DB backup and 4.1 files, but still can’t access web UI.

Thoughts?

I have tried to install 4.2.1 from 4.1.2 and it broke my mautic.

I have restored a backup and, after a little research, I have discovered this:

The cron processes related to campaigns do never ends. They achieves the 100% but never ends. According to the log, there is an error adding some contacts to a campaign. I have seen that those contacts already are in those campaigns. The process tries to add them over and over, and never ends.

Looking into the contacts filters, I have seen that they are broken. For instance, there was a segment with no filters because the contacts where added and removed from campaigns actions. After the update, that segment has filters and the combos of the conditions are empty and combo boxes are empty and unselectable. Other filter had a “URL visited” condition, after update, the combo of that condition is empty and, when I open it, there is no options to select.

I guess it means that the update process has broke the database.

Maybe we could do a progressive update from 4.1.0 to 4.2.1 updating each intermediate version but I h haven’t found info about how to manually install a selected version.

Edited:
I have found how to do an incremental upgrade using zip file, but it has a big limitation. I have to create a new mautic folder and move all files I have change (media/files; plugins; themes; translations) from current installation but… I’m not sure which files I have modified and, because I restored a backup, all files has the same time stamp :frowning:

1 Like

I also was not able to restore the backup but I found a workaround.

In my case, I restored all subdomain files and database using the hosting (Siteground) tools. This caused an strange PHP error. The solution was to restore the mautic folder to another folder, delete the broken mautic folder and copy the restored mautic folder to its original place.

I guess than something happened when I delete and replace the mautic folder and “that thing” didn’t happen when I restore the files from backup.

Everything is working again.

1 Like

I reverted back to my old 4.1 and it finally worked. Pretty sure the DB is a hybrid of both versions now, but don’t care because it’s up and running again. I am NEVER upgrading after all the garbage/stress I had to go through to get my system back. :rage:

1 Like

Upgrading via UI is going away in Mautic 5.x so CLI upgrades are the mainstream. Run a schema update to ensure your update is complete.

Yeah, I read that. Thought I was safe using the v4 manual upgrade approach still, but that was clearly not the case. As I said, I am currently using files from 4.1 with a database that says I am “up to date with 4.2.1”! Yay? Not even sure how it’s working right now, frankly, but I am not going to touch anything until version 5.5 at the least…

1 Like

Spoke too soon, apparently having deeper DB issues. Getting this error now:

SQLSTATE[HY000]: General error: 3780 Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'FK_BLAHBLAHBLAH' are incompatible.

Anyone have an idea how to correct this in my database?

Okay, found the web UI problem: A line in my .htaccess file was preventing anything from showing. I uncommented it, and Mautic is showing up again, but I still have the same error message noted above.

I think I can manually edit the DB table to fix this, but I want to make sure I am interpreting the failure (and solution) correctly:

In TABLE oauth2_accesstokens, I need to CHANGE the user_id to: “INT UNSIGNED DEFAULT NULL,” and then CHANGE the client_id to “INT UNSIGNED NOT NULL,” and CHANGE the token to “VARCHAR(191) NOT NULL,” and CHANGE the scope to VARCHAR(191) DEFAULT NULL"

Am I reading that right?