ichtrojan / laravel-location

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

Some cities are not getting country_id #31

Closed cacpmw closed 4 years ago

cacpmw commented 4 years ago

@ichtrojan the seeders run flawlessly but I noticed some cities didnt get country_id. Is that how it is supposed to be?

image

ichtrojan commented 4 years ago

It shouldn't be, @djunehor help needed here #26

djunehor commented 4 years ago

I'll take a look at it

ichtrojan commented 4 years ago
Screenshot 2020-01-10 at 10 41 02

@cacpmw run:

php artisan migrate:refresh

Followed by:

php artisan db:seed --class=Ichtrojan\\Location\\Seeds\\LocationDatabaseSeeder

This should fix the issue, I just replicated this on my end.

djunehor commented 4 years ago

The reason I won't recommend php artisan migrate:refresh is cos that'll lead to loss of data on a DB with existing data. Location tables aren't and won't be the only tables in the DB and that command drops all tables (not just location tables)

php artisan migrate should suffice (it'll run the needed migrations). Then php artisan db:seed --class=Ichtrojan\\Location\\Seeds\\LocationDatabaseSeeder, which will attempt to repopulate the location tables (might fail if location tables have existing data). I suspect the bug is as a result of old data in the DB.

I've created a PR (#33) to resolve that as well as factor in issue #30 (disable foreign key check before truncating)

@cacpmw please let's know if the issue is rectified.

cacpmw commented 4 years ago

@ichtrojan @djunehor sorry late answer. I was away. I will test it ASAP

ichtrojan commented 4 years ago

any luck @cacpmw?