From 89a7fd2d8c72334b6dfd7434c532bfb5519b7170 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Tue, 6 Aug 2024 13:01:43 -0400 Subject: [PATCH] Refs #37678 - 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..2d26577a 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!("runuser -l postgres -c \"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