Skip to content

Updating Records

yurtesen edited this page Aug 11, 2016 · 5 revisions

Geonames provide only updates for previous day only. It is not very convenient to use because you would need to regularly fetch the file everyday. While this can be scripted, you can never find out what was changed, if for some reason you can't fetch the file for a day.

Unfortunately currently the daily update files are not supported. But there is a workaround for this problem.

Luckily there are not many deletes for the geonames main table. There seems to be much more delete actions in alternate names table. It is possible to update existing records by simply re-seeding them. This will NOT delete any existing records but it will simply update their contents.

Update Methods

1. Using the Daily Updates

Unfortunately daily update files are not supported yet. This will be added in future as a feature.

2. Re-Seeding Tables

You can simply run artisan to re-seed tables without deleting existing information. This will simply do update if record exists or insert if record do not exist. This operation may take several hours to complete depending on your indices. It is recommended to run it from a 'screen' session so you may re-connect if you get disconnected at any point.

php artisan geonames:seed --update-files

This operation takes about 180 minutes in a VM which I use on my laptop with 5400RPM drive and 2GB RAM allocated to VM. Depending on your indices, it may go faster or slower on your server (probably faster). However it is not of any consequence since tables should continue to be working during the process.

Note: If you want to truncate the tables you may use the --refresh option of the seed command. However this will delete all existing records in geonames tables. Therefore if your site is using the records, you will have problems until they are re-populated.

Clone this wiki locally