Skip to content

Commit

Permalink
Refs #37797 - ensure we can start PostgreSQL by forcing the old version
Browse files Browse the repository at this point in the history
Something (f-m) might have already called switch-to postgresql:13, which
- upgraded packages
- tried to restart services

The later obviously fails as the on-disk data is in the wrong format.
  • Loading branch information
evgeni committed Sep 10, 2024
1 parent c35c1e3 commit 3907c25
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hooks/boot/06-postgresql-upgrade-extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

module PostgresqlUpgradeHookContextExtension
def needs_postgresql_upgrade?(new_version)
File.read('/var/lib/pgsql/data/PG_VERSION').chomp.to_i < new_version.to_i
current_version.to_i < new_version.to_i
rescue Errno::ENOENT
false
end

def current_version
File.read('/var/lib/pgsql/data/PG_VERSION').chomp
end

def os_needs_postgresql_upgrade?
el8? && needs_postgresql_upgrade?(13)
end

def postgresql_upgrade(new_version)
logger.notice("Performing upgrade of PostgreSQL to #{new_version}")

execute!("dnf module switch-to postgresql:#{current_version} -y", false, true)
start_services(['postgresql'])
postgres_list = `runuser -l postgres -c 'psql --list --tuples-only --csv'`
postgres_databases = CSV.parse(postgres_list)
Expand Down

0 comments on commit 3907c25

Please sign in to comment.