ichtrojan / laravel-location

A simple Laravel Package to sort Countries, States and Cities
MIT License
205 stars 44 forks source link

Cannot truncate a table referenced in a foreign key constraint #29

Closed cacpmw closed 4 years ago

cacpmw commented 4 years ago

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

cacpmw commented 4 years ago

@ichtrojan can you do this for me?