ichtrojan/laravel-location

Cannot truncate a table referenced in a foreign key constraint

cacpmw opened this issue · 1 comments

I've need to use the cities table as a FK in another table. But the seeders call db:truncate before seeding and thus I get this error:

Cannot truncate a table referenced in a foreign key constraint (db.addresses, CONSTRAINT addresses_city_id_foreign FOREIGN KEY (city_id) REFERENCES db.cities (id)) (SQL: truncate cities)

There is no need for db:truncate since we can use migrate:refresh or migrate:fresh to reset the entire database and keep the integrity of the ids.

PR #30

@ichtrojan can you do this for me?