fias icon indicating copy to clipboard operation
fias copied to clipboard

Update db.rake

Open bulychev-ay opened this issue 9 years ago • 7 comments

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

bulychev-ay avatar May 08 '15 12:05 bulychev-ay

It's unpredictably. If you want to create few tables - you can specify TABLES option for a rake.

gzigzigzeo avatar May 08 '15 12:05 gzigzigzeo

https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions

gzigzigzeo avatar May 08 '15 12:05 gzigzigzeo

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?

bulychev-ay avatar May 12 '15 10:05 bulychev-ay

  1. 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.

gzigzigzeo avatar May 12 '15 10:05 gzigzigzeo

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.

bulychev-ay avatar May 12 '15 10:05 bulychev-ay

Am I correct that you are updating just data, not the table structure?

gzigzigzeo avatar May 14 '15 12:05 gzigzigzeo

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

bulychev-ay avatar Jun 02 '15 11:06 bulychev-ay