I'm getting this following error
[Application] Jan 5 00:03:10 |CRITICA| CONSOL Error thrown while running command "make:migration". Message: "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1052 Champ: 'TABLE_NAME' dans where clause est ambigu
When running the migration command after creating the user entity
created: src/Entity/User.php
created: src/Repository/UserRepository.php
updated: src/Entity/User.php
updated: config/packages/security.yaml
Success!
Next Steps:
- Review your new App\Entity\User class.
- Use make:entity to add more fields to your User entity and then run make:migration.
- Create a way to authenticate! See https://symfony.com/doc/current/security.html PS C:\Users\chris\Desktop\projets\Matehub-Api> php bin/console make:migration
In ExceptionConverter.php line 72: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1052 Champ: 'TABLE_NAME' dans where clause est ambigu
`
I don't really get what is happening considering that I just used the symfony command to generate the User class.
Ive been able to create the database without any issue using
php bin/console doctrine:database:create
THis is what I have in dev.log file
[2024-01-05T00:03:10.055039+00:00] doctrine.DEBUG: Executing statement: SELECT c.TABLE_NAME, c.COLUMN_NAME AS field, IF( c.COLUMN_TYPE = 'longtext' AND EXISTS( SELECT * from information_schema.CHECK_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = 'matehub' AND TABLE_NAME = c.TABLE_NAME AND CHECK_CLAUSE = CONCAT( 'json_valid(
', c.COLUMN_NAME, ')' ) ), 'json', c.COLUMN_TYPE ) AS type, c.IS_NULLABLE ASnull, c.COLUMN_KEY ASkey, c.COLUMN_DEFAULT ASdefault, c.EXTRA, c.COLUMN_COMMENT AS comment, c.CHARACTER_SET_NAME AS characterset, c.COLLATION_NAME AS collation FROM information_schema.COLUMNS c INNER JOIN information_schema.TABLES t ON t.TABLE_NAME = c.TABLE_NAME WHERE c.TABLE_SCHEMA = ? AND t.TABLE_SCHEMA = ? AND t.TABLE_TYPE = 'BASE TABLE' ORDER BY ORDINAL_POSITION (parameters: array{"1":"matehub","2":"matehub"}, types: array{"1":2,"2":2}) {"sql":"SELECT c.TABLE_NAME, c.COLUMN_NAME AS field,\n IF(\n c.COLUMN_TYPE = 'longtext'\n AND EXISTS(\n SELECT * from information_schema.CHECK_CONSTRAINTS \n WHERE CONSTRAINT_SCHEMA = 'matehub'\n AND TABLE_NAME = c.TABLE_NAME\n AND CHECK_CLAUSE = CONCAT(\n 'json_valid(',\n c.COLUMN_NAME,\n ')'\n )\n ),\n 'json',\n c.COLUMN_TYPE\n ) AS type,\n c.IS_NULLABLE ASnull,\n c.COLUMN_KEY ASkey,\n c.COLUMN_DEFAULT ASdefault,\n c.EXTRA,\n c.COLUMN_COMMENT AS comment,\n c.CHARACTER_SET_NAME AS characterset,\n c.COLLATION_NAME AS collation\nFROM information_schema.COLUMNS c\n INNER JOIN information_schema.TABLES t\n ON t.TABLE_NAME = c.TABLE_NAME\n WHERE c.TABLE_SCHEMA = ? AND t.TABLE_SCHEMA = ? AND t.TABLE_TYPE = 'BASE TABLE' ORDER BY ORDINAL_POSITION","params":{"1":"matehub","2":"matehub"},"types":{"1":2,"2":2}} []
[2024-01-05T00:03:10.059570+00:00] console.CRITICAL: Error thrown while running command "make:migration". Message: "An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1052 Champ: 'TABLE_NAME' dans where clause est ambigu" {"exception":"[object] (Doctrine\DBAL\Exception\NonUniqueFieldNameException(code: 1052): An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1052 Champ: 'TABLE_NAME' dans where clause est ambigu at C:\Users\chris\Desktop\projets\MateHub-Api\vendor\doctrine\dbal\src\Driver\API\MySQL\ExceptionConverter.php:72)\n[previous exception] [object] (Doctrine\DBAL\Driver\PDO\Exception(code: 1052): SQLSTATE[23000]: Integrity constraint violation: 1052 Champ: 'TABLE_NAME' dans where clause est ambigu at C:\Users\chris\Desktop\projets\MateHub-Api\vendor\doctrine\dbal\src\Driver\PDO\Exception.php:28)\n[previous exception] [object] (PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1052 Champ: 'TABLE_NAME' dans where clause est ambigu at C:\Users\chris\Desktop\projets\MateHub-Api\vendor\doctrine\dbal\src\Driver\PDO\Statement.php:130)","command":"make:migration","message":"An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1052 Champ: 'TABLE_NAME' dans where clause est ambigu"} []
EDIT : Actually I think this might not be related to the User entity but to the installation itself as the error seems to remain even if I remove the User entity and repository
Check your
.envfile for your DATABASE_URL and make sure the "serverVersion" is correct.For instance, if connecting to MySQL 8, make sure it doesn't say "serverVersion=10.11.2-MariaDB", etc