Skip to content

Commit

Permalink
Bug fix with multiple PG installations.
Browse files Browse the repository at this point in the history
Reverse hashmap of pg_version helpers

Style correction modify variable name

Remove commented code

Signed-off-by: Justin Fernbaugh <fernbaughj@gmail.com>

Revert minor bump

Signed-off-by: Justin Fernbaugh <fernbaughj@gmail.com>

Sort array with highest PG version first

Add changelog note

Signed-off-by: Justin Fernbaugh <fernbaughj@gmail.com>
  • Loading branch information
Justin-Fernbaugh committed Dec 14, 2023
1 parent f136f53 commit 2f28fa1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This file is used to list changes made in the last 3 major versions of the postg

## Unreleased

- Fix installed_postgresql_* helper functions to maintain PG version consistency.

## 11.8.3 - *2023-10-31*

## 11.8.2 - *2023-09-28*
Expand Down
8 changes: 8 additions & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ module Helpers

def installed_postgresql_major_version
pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) }
pgsql_package = pgsql_package.sort_by do |key, _values|
version_match = key.match(/^postgresql(\d+)/)
version_match ? version_match[1].to_i : 0
end.to_h

raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package)

Expand All @@ -43,6 +47,10 @@ def installed_postgresql_major_version

def installed_postgresql_package_source
pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) }
pgsql_package = pgsql_package.sort_by do |key, _values|
version_match = key.match(/^postgresql(\d+)/)
version_match ? version_match[1].to_i : 0
end.reverse.to_h

raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package)

Expand Down

0 comments on commit 2f28fa1

Please sign in to comment.