我的猜测是使用以下语法:
MyModel::all()->delete();
Run Code Online (Sandbox Code Playgroud)
但那没用.我确信它非常简单,但我已经搜索了关于这个主题的文档而无法找到它!
我正在尝试运行迁移(见下文)并为数据库播种,但是当我运行时
php artisan migrate --seed
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Migration table created successfully.
Migrated: 2015_06_17_100000_create_users_table
Migrated: 2015_06_17_200000_create_password_resets_table
Migrated: 2015_06_17_300000_create_vehicles_table
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table
referenced in a foreign key constraint (`app`.`vehicles`, CONSTRAINT `vehic
les_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `app`.`users` (`id`
)) (SQL: truncate `users`)
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table
referenced in a foreign key constraint (`app`.`vehicles`, CONSTRAINT `vehic
les_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `app`.`users` (`id`
))
Run Code Online (Sandbox Code Playgroud)
我查看了这个错误应该是什么意思,并且还找到了遇到同样问题的其他人的 …