Skip to content

Commit

Permalink
Move logic for dropping pglogical extension to a separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
gtanzillo authored and NickLaMuro committed Mar 16, 2021
1 parent 98701fb commit ef6e1a3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/manageiq/appliance_console/postgres_admin.rb
Expand Up @@ -111,18 +111,24 @@ def self.restore(opts)
end

def self.before_restore(opts)
# Drop subscriptions, unload extension and ensure pglogical connections are closed before proceeding
unload_pglogical_extension(opts)
rescue AwesomeSpawn::CommandResultError
$log.info("MIQ(#{name}.#{__method__}) Ignoring failure to remove pglogical before restore ...")
end

def self.unload_pglogical_extension(opts)
runcmd("psql", opts, :command => <<-SQL)
SELECT
drop_subscription
FROM
pglogical.subscription subs,
LATERAL pglogical.drop_subscription(subs.sub_name)
SQL

runcmd("psql", opts, :command => <<-SQL)
DROP EXTENSION pglogical CASCADE
SQL
rescue AwesomeSpawn::CommandResultError
$log.info("MIQ(#{name}.#{__method__}) Ignoring failure to remove pglogical before restore ...")
end

def self.backup_compress_with_gzip
Expand Down

0 comments on commit ef6e1a3

Please sign in to comment.