Symfony执行doctrine:fixtures:load触发semestre_id非空约束错误求助
Symfony 6.3加载Doctrine Fixtures时触发非空约束错误
在Symfony 6.3本地开发环境中,执行命令symfony console doctrine:fixtures:load加载数据fixtures时,遇到以下错误:
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]
已尝试的操作
- 检查数据库服务器状态:确认MySQL正在运行
- 验证
.env配置:文件包含DATABASE_URL="mysql://root:@127.0.0.1:3306/GestionExams?serverVersion=10.4.21-MariaDB&charset=utf8mb4" - 测试数据库连接:可通过MySQL客户端正常连接
- 清除Symfony缓存:执行
php bin/console cache:clear排除缓存问题
额外信息
- Symfony版本:6.3
- 数据库:MySQL
- 项目仓库:marouane-sadoune/GEXAMS(GitHub)
内容的提问来源于stack exchange,提问作者Marouane Sadoune
相关产品推荐
相关产品推荐

