I’m trying to load fixtures in my Symfony project using the command:
symfony console doctrine:fixtures:load
However, I’m encountering the following error:
Careful, database "gestionexams" will be purged. Do you want to continue? (yes/no) [no]:
> yes
> purging database
> loading App\DataFixtures\AppFixtures
In ExceptionConverter.php line 115:
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'semestre_id' cannot be null
In Exception.php line 24:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'semestre_id' cannot be null
In Statement.php line 130:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'semestre_id' cannot be null
doctrine:fixtures:load [--append] [--group GROUP] [--em EM] [--purger PURGER] [--purge-exclusions PURGE-EXCLUSIONS] [--purge-with-truncate]
What I’ve Tried:
- Checked Database Server Status: Confirmed that MySQL/PostgreSQL is running.
- Verified
.env
Configuration: My.env
file contains:
DATABASE_URL="mysql://root:@127.0.0.1:3306/GestionExams?serverVersion=10.4.21-MariaDB&charset=utf8mb4"
- Tested Database Connection: I can connect to the database using a database client MySQL
- Cleared Symfony Cache: i run
php bin/console cache:clear
to ensure the cache isn’t causing the issue.
Additional Information:
Symfony Version: 6.3.
Database: MySQL.
Environment: Local development .
Relevant Code: My
DATABASE_URL
in.env
is:
DATABASE_URL="mysql://root:@127.0.0.1:3306/GestionExams?serverVersion=10.4.21-MariaDB&charset=utf8mb4"
- this my (repo)[] repo
I’m trying to load fixtures in my Symfony project using the command:
symfony console doctrine:fixtures:load
However, I’m encountering the following error:
Careful, database "gestionexams" will be purged. Do you want to continue? (yes/no) [no]:
> yes
> purging database
> loading App\DataFixtures\AppFixtures
In ExceptionConverter.php line 115:
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'semestre_id' cannot be null
In Exception.php line 24:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'semestre_id' cannot be null
In Statement.php line 130:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'semestre_id' cannot be null
doctrine:fixtures:load [--append] [--group GROUP] [--em EM] [--purger PURGER] [--purge-exclusions PURGE-EXCLUSIONS] [--purge-with-truncate]
What I’ve Tried:
- Checked Database Server Status: Confirmed that MySQL/PostgreSQL is running.
- Verified
.env
Configuration: My.env
file contains:
DATABASE_URL="mysql://root:@127.0.0.1:3306/GestionExams?serverVersion=10.4.21-MariaDB&charset=utf8mb4"
- Tested Database Connection: I can connect to the database using a database client MySQL
- Cleared Symfony Cache: i run
php bin/console cache:clear
to ensure the cache isn’t causing the issue.
Additional Information:
Symfony Version: 6.3.
Database: MySQL.
Environment: Local development .
Relevant Code: My
DATABASE_URL
in.env
is:
DATABASE_URL="mysql://root:@127.0.0.1:3306/GestionExams?serverVersion=10.4.21-MariaDB&charset=utf8mb4"
- this my (repo)[https://github/marouane-sadoune/GEXAMS] repo
1 Answer
Reset to default 1You need to make the field nullable in the entity file, then update de database, then try again
null
for "semester", or set a value to "semester_id". – yivi Commented Mar 9 at 10:50