Skip to content

Commit

Permalink
Refs #37883 - check if evr extension exists on remote DBs
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed Nov 15, 2024
1 parent 3c6ef7e commit 3447f12
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hooks/pre_commit/42-evr_extension_permissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
# If postgres is the owner of the DB, then the permissions will not matter.
return if config[:username] == 'postgres'

evr_existence_command = pg_sql_statement("SELECT 1 FROM pg_extension WHERE extname = 'evr';")
logger.debug "Checking if the evr extension exists via #{evr_existence_command}"
evr_existence_output, = execute_command(evr_existence_command, false, true, pg_env(config))

# If the evr extension does not exist, then we can skip this check.
return if evr_existence_output&.strip != '1'

check_evr_owner_sql = "SELECT CASE" \
" WHEN r.rolname = '#{config[:username]}' THEN 0" \
" ELSE 1" \
Expand Down

0 comments on commit 3447f12

Please sign in to comment.