From 3447f12cf8fa87507ed79d983b6340eeecae9d86 Mon Sep 17 00:00:00 2001 From: Ian Ballou Date: Fri, 15 Nov 2024 16:34:11 -0500 Subject: [PATCH] Refs #37883 - check if evr extension exists on remote DBs --- hooks/pre_commit/42-evr_extension_permissions.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hooks/pre_commit/42-evr_extension_permissions.rb b/hooks/pre_commit/42-evr_extension_permissions.rb index e9254f73..836d7cd9 100644 --- a/hooks/pre_commit/42-evr_extension_permissions.rb +++ b/hooks/pre_commit/42-evr_extension_permissions.rb @@ -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" \