Mautic Community Forums

Error while upgrading from 3.3.4 to 4.0

Your software
My PHP version is : 7.4
My MySQL/MariaDB version is (delete as applicable): MySQL/MariaDB version 10.3.31-MariaDB-log-cll-lve

Updating/Installing Errors
I am: Updating
Upgrading via : Web

These errors are showing in the installer :

These errors are showing in the Mautic log :

[2021-08-30 18:44:08] console.CRITICAL: Error thrown while running command “doctrine:migrations:migrate --no-interaction --env=prod --no-debug”. Message: “An exception occurred while executing ‘ALTER TABLE oauth2_clients ADD CONSTRAINT FK_CLIENT_ROLE FOREIGN KEY (role_id) REFERENCES roles (id)’: SQLSTATE[HY000]: General error: 1005 Can’t create table dbname.oauth2_clients (errno: 150 “Foreign key constraint is incorrectly formed”)” {“exception”:"[object] (Doctrine\DBAL\Exception\DriverException(code: 0): An exception occurred while executing ‘ALTER TABLE oauth2_clients ADD CONSTRAINT FK_CLIENT_ROLE FOREIGN KEY (role_id) REFERENCES roles (id)’:\n\nSQLSTATE[HY000]: General error: 1005 Can’t create table dbname.oauth2_clients (errno: 150 “Foreign key constraint is incorrectly formed”) at /path_to_mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:128, Doctrine\DBAL\Driver\PDO\Exception(code: HY000): SQLSTATE[HY000]: General error: 1005 Can’t create table dbname.oauth2_clients (errno: 150 “Foreign key constraint is incorrectly formed”) at /path_to_mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1005 Can’t create table dbname.oauth2_clients (errno: 150 “Foreign key constraint is incorrectly formed”) at /path_to_mautic/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:132)",“command”:“doctrine:migrations:migrate --no-interaction --env=prod --no-debug”,“message”:“An exception occurred while executing ‘ALTER TABLE oauth2_clients ADD CONSTRAINT FK_CLIENT_ROLE FOREIGN KEY (role_id) REFERENCES roles (id)’:\n\nSQLSTATE[HY000]: General error: 1005 Can’t create table dbname.oauth2_clients (errno: 150 “Foreign key constraint is incorrectly formed”)”}

Your problem
My problem is : i was running versione 3.2.4. I updatet via web interface to 3.2.5 and then to 3.3.4 and everything goes well

then i tried to update from 3.3.4 to 4 and everything goes well until the last step “database updade” that returns an error. Then i saw in the log file and there was the error i pasted above.

then i restored a backup of mautic directory and a backup of the database and i’m still running 3.3.4… someone knows what i can do?

thanks :slight_smile:

Steps I have tried to fix the problem :

Hey, is this an instance, that you upgraded from M2 ? There was an issue with the M2->M3 upgrades which caused the same problems. I also have a couple of instances, that are stuck with 3.3.3 because of the same reason.
Migrations won’t run due to key constrains.
I looked at:

and:

Thanks! I’ll take a look to the links you posted! :kissing: