Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add citext for all databases in postgres

  • Loading branch information...
commit 835e586e92cc33b9764dfee824d58856bed7c671 1 parent f1db0d7
Dennis Schmidt & Doc Ritezel authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 recipes/postgres_citext.rb
View
13 recipes/postgres_citext.rb
@@ -1,7 +1,12 @@
include_recipe "pivotal_workstation::postgres"
-execute "install the citext module" do
- command "/usr/local/bin/psql -U postgres -c 'CREATE EXTENSION citext'"
- user WS_USER
- not_if "/usr/local/bin/psql -U postgres -c '\\dT' | grep -i citext"
+postgres_databases = `psql -U postgres -c '\\list' | cut -d' ' -f 2 | grep -v '^template' | tail +4`.split("\n")
+
+# the last 4 lines are noise from psql
+postgres_databases[0...-4].each do |database|
+ execute "install the citext module into #{database}" do
+ command "/usr/local/bin/psql -U postgres -d #{database} -c 'CREATE EXTENSION citext'"
+ user WS_USER
+ not_if "/usr/local/bin/psql -U postgres -d #{database} -c '\\dT' | grep -i citext"
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.