When I run php bin/console doctrine:schema:update --force
, I get the following error messages:
In AbstractMySQLDriver.php line 128:
An exception occurred while executing 'ALTER TABLE oauth2_clients CHANGE id id INT UNSIGNED AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(191) NOT NULL, CHANGE random_id random_id VARCHAR(191) NOT NULL, CHANGE secret secret VARCHAR(191) NOT NULL':
SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'FK_818C32519EB6921' of table 'mymauticdb.oauth2_accesstokens'
In Exception.php line 18:
SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'FK_818C32519EB6921' of table 'mymauticdb.oauth2_accesstokens'
In PDOConnection.php line 141:
SQLSTATE[HY000]: General error: 1833 Cannot change column 'id': used in a foreign key constraint 'FK_818C32519EB6921' of table 'mymauticdb.oauth2_accesstokens'
doctrine:schema:update [--em EM] [--complete] [--dump-sql] [-f|--force] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
What does this mean? How could I fix it? What could I manually check, change, âresetâ in the database (via PhpMyAdmin)?
I usually ignore these errors, without any noticeable issues, but I now have a serious import problem that may be related.
Several people posted the same/similar problem here (2021-22), without a solution. Several others reported the same issue here. Also discussion here and here.
@maumatic apparently has a solution here. The closest thing found on that link that looks like it might be a solution is this recipe - complicated and scary looking, will try this laterâŚ
Or was this fixed around/after version 3.3.1, @rcheesley? I see it was reopened as issue.
Edit:
I am trying to follow the instructions here, but am stuck at the SQL via command line stuff. I guess I have to enter my database credentials in those lines, like:
mysql -h"localhost" -u"mydbuser" -p"mydbpassword" -N -B -e 'SELECT concat("ALTER TABLE ", TABLE_NAME, " DROP FOREIGN KEY ", CONSTRAINT_NAME, ";") FROM information_schema.key_column_usage WHERE CONSTRAINT_SCHEMA = "mautic" AND referenced_table_name IS NOT NULL' > schema_update_constraints.sql
But I get error -bash: !p@E": event not found
âŚ
Is the syntax correct? Lots of " and '⌠Am I supposed to replace TABLE_NAME
and referenced_table_name
with something else?
Edit2:
If I replace double quotes with single quotes and add spaces, it does go through:
mysql -h 'localhost' -u 'mydbuser' -p 'mydbpassword' -N -B -e 'SELECT concat("ALTER TABLE ", TABLE_NAME, " DROP FOREIGN KEY ", CONSTRAINT_NAME, ";") FROM information_schema.key_column_usage WHERE CONSTRAINT_SCHEMA = "mautic" AND referenced_table_name IS NOT NULL' > schema_update_constraints.sql
It then asks for a password, but the next response is Access denied for user 'mydbuser'@'localhost' (using password: YES)
. Should I do this as root?
Edit3:
Is this issue solved in 4.4.2? Or will upgrading cause a bigger mess?
Your software
My Mautic version is: v4.4.1
My PHP version is: 7.4.30
My Database type and version is: 10.3.36-MariaDB