Skip to content

Update db.rake#4

Open
bulychev-ay wants to merge 1 commit intoevilmartians:masterfrom
bulychev-ay:patch-3
Open

Update db.rake#4
bulychev-ay wants to merge 1 commit intoevilmartians:masterfrom
bulychev-ay:patch-3

Conversation

@bulychev-ay
Copy link
Contributor

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

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
@gzigzigzeo
Copy link
Contributor

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

@gzigzigzeo
Copy link
Contributor

@bulychev-ay
Copy link
Contributor Author

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?

@gzigzigzeo
Copy link
Contributor

  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.

@bulychev-ay
Copy link
Contributor Author

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.

@gzigzigzeo
Copy link
Contributor

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

@bulychev-ay
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants