fias
fias copied to clipboard
Update db.rake
If handle errors(e.g. PG::DuplicateTable) like this in case if the tables already exist we can update whole database 'fias' but not just initialize
It's unpredictably. If you want to create few tables - you can specify TABLES option for a rake.
https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
I want to update whole database using your tasks. Maybe if we handle just 'PG::DuplicateTable' exception, we are not lose control over the code behavior?
- Could you please explain your case? Why do you need this bulk update? Why do not you want to just specify the list of tables which are not exists? 2) I think it would be more correct to add TABLES=missing param to handle this exception.
If there is a working, but old FIAS database which updated irregularly, I think it would be easier to do a full refresh to actualize it. I checked - it can be done successfully by using your tasks, in case of bypass the exception 'PG::DuplicateTable' It would be an option for sheduler, which it choose if routine update has not been done for long time for any reason.
Am I correct that you are updating just data, not the table structure?
Yes, just updating date. It can be solved by another ways, like using ActiveRecord::Base.connection.tables.include?("table_name") method to check existence of the table before trying to create it. Or i wrote method, that deletes all existing tables which tied to fias models in local DB - and call it before start full updating. So you can to reject this commit - no need to change body of the gem