From 13d9cc27cfb494d3c5571fb25260ba8908825f96 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Tue, 6 Aug 2024 13:01:43 -0400 Subject: [PATCH] Refs #11098 - Update evr extension ownership after postgresql upgrade --- hooks/boot/06-postgresql-upgrade-extensions.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hooks/boot/06-postgresql-upgrade-extensions.rb b/hooks/boot/06-postgresql-upgrade-extensions.rb index fe76c8b1..5f3fc869 100644 --- a/hooks/boot/06-postgresql-upgrade-extensions.rb +++ b/hooks/boot/06-postgresql-upgrade-extensions.rb @@ -43,6 +43,11 @@ def postgresql_upgrade(new_version) execute_as!('postgres', 'vacuumdb --all --analyze-in-stages', false, true) + if new_version.to_i == 13 + logger.notice("Updating ownership of the evr extension if upgrading to postgres version 13") + execute_as!('postgres', "psql -d foreman -c \"UPDATE pg_extension SET extowner = (SELECT oid FROM pg_authid WHERE rolname = 'foreman') WHERE extname = 'evr';\"", false, true) + end + logger.notice("Upgrade to PostgreSQL #{new_version} completed") end