Skip to content

Commit

Permalink
Do the restore without any active connections to the database
Browse files Browse the repository at this point in the history
To do this, we need to disconnect the connection we created when
requiring the :environment rake task to run this method.
  • Loading branch information
carbonin committed Feb 12, 2018
1 parent 4d7af02 commit e574ad3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/evm_database_ops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ def self.restore(db_opts, connect_opts = {})

prepare_for_restore(db_opts[:local_file])

backup = PostgresAdmin.restore(db_opts)
# remove all the connections before we restore; AR will reconnect on the next query
ActiveRecord::Base.connection_pool.disconnect!
backup_file = PostgresAdmin.restore(db_opts)
ensure
session.disconnect if session
end

uri ||= backup
uri ||= backup_file
_log.info("[#{db_opts[:dbname]}] database has been restored from file: [#{uri}]")
uri
end
Expand Down

0 comments on commit e574ad3

Please sign in to comment.