Skip to content

Commit

Permalink
Quick fix for fetch(:pg_database) on extension adding
Browse files Browse the repository at this point in the history
  • Loading branch information
NorseGaud committed Jun 6, 2018
1 parent ae71112 commit c52a2b6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### master

## v5.0.1, 2018-06-05
- Quick fix for fetch(:pg_database) on extension adding

## v5.0.0, 2018-06-05
- Code cleanup
- Removal of legacy add hstore method
Expand Down
4 changes: 2 additions & 2 deletions lib/capistrano/postgresql/helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Postgresql
module HelperMethods

def extension_exists?(extension)
psql 'test', fetch(:pg_system_db), '-tAc', %Q{"SELECT 1 FROM pg_extension WHERE extname='#{extension}';" | grep -q 1}
psql 'test', fetch(:pg_database), '-tAc', %Q{"SELECT 1 FROM pg_extension WHERE extname='#{extension}';" | grep -q 1}
end

def remove_extensions
Expand All @@ -14,7 +14,7 @@ def remove_extensions
# remove in reverse order if extension is present
Array( fetch(:pg_extensions) ).reverse.each do |ext|
next if [nil, false, ""].include?(ext)
psql 'execute', fetch(:pg_system_db), '-c', %Q{"DROP EXTENSION IF EXISTS #{ext};"} if extension_exists?(ext)
psql 'execute', fetch(:pg_database), '-c', %Q{"DROP EXTENSION IF EXISTS #{ext};"} if extension_exists?(ext)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/postgresql/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Capistrano
module Postgresql
VERSION = '5.0.0'
VERSION = '5.0.1'
end
end
2 changes: 1 addition & 1 deletion lib/capistrano/tasks/postgresql.rake
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace :postgresql do
if Array( fetch(:pg_extensions) ).any?
Array( fetch(:pg_extensions) ).each do |ext|
next if [nil, false, ''].include?(ext)
psql 'execute', fetch(:pg_system_db), '-c', %Q{"CREATE EXTENSION IF NOT EXISTS #{ext};"}unless extension_exists?(ext)
psql 'execute', fetch(:pg_database), '-c', %Q{"CREATE EXTENSION IF NOT EXISTS #{ext};"}unless extension_exists?(ext)
end
end
end
Expand Down

0 comments on commit c52a2b6

Please sign in to comment.