Closed

Description
If you attempt to use seeding on a table with foreign key constraints, an exception will be thrown as truncate operations are not permitted on tables with foreign keys.
That said, is truncate necessary as part of the seeding? If you are populating an empty database having run a migration, then there is no need to truncate as all of your tables are empty.
If you use php artisan migrate:refresh --seed
then all your migrations will be rolled back and restarted - which again would mean that there is no need for a truncate operation since your tables are once again empty?
php artisan db:seed --env=local
[Exception]
SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a t
able referenced in a foreign key constraint (`database`.`projects`, CON
STRAINT `projects_client_id_foreign` FOREIGN KEY (`client_id`) REFERENCES `
database`.`clients` (`id`)) (SQL: truncate `clients`) (Bindings: array
(
))
db:seed [--database[="..."]]
Metadata
Metadata
Assignees
Labels
No labels