Skip to content

Commit c98f160

Browse files
authored
Merge pull request #6 from cloudfoundry-community/extensions
Added ability to customize pg databases with extensions
2 parents e459691 + 935a193 commit c98f160

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

ci/release_notes.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Improvements
2+
3+
- When custom databases are created, the manifest can be used to
4+
specify any PG extensions that need to be loaded via the `extensions`
5+
array attribute on the database.
6+
Example:
7+
8+
```
9+
properties:
10+
pgpool:
11+
databases:
12+
- name: animals
13+
extensions:
14+
- citext
15+
- pgcrypto
16+
```

jobs/postgres/spec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,5 @@ properties:
100100
users:
101101
- porcupine
102102
- hedgehog
103+
extensions: # optional aray of extensions to enable on this database
104+
- citext

jobs/postgres/templates/bin/ctl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,18 @@ EOF
124124
echo >>$LOG_DIR/$JOB_NAME.log "[postgres] setting up database <%= database['name'] %>"
125125
set -x
126126

127-
createdb -U vcap -p <%= port %> -O vcap <%= database['name'] %>
128-
127+
createdb -U vcap -p <%= port %> -O vcap <%= database['name'] %>
129128
<% database['users'].each do |user| %>
130129
psql -p <%= port %> -U vcap postgres -c "GRANT ALL PRIVILEGES ON DATABASE \"<%= database['name'] %>\" TO \"<%= user %>\""
131130
<% end %>
132131

132+
<% if database["extensions"]
133+
database["extensions"].each do |ext| %>
134+
echo "Trying to install <%= ext %>..."
135+
psql -p <%= port %> -U vcap "<%= database['name'] %>" -c "CREATE EXTENSION IF NOT EXISTS <%= ext %>"
136+
<% end
137+
end %>
138+
133139
set +x
134140
echo
135141

packages/postgres/packaging

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ VERSION=9.5.1
1313
tar -xjf postgres/postgresql-${VERSION}.tar.bz2
1414
cd postgresql-${VERSION}/
1515
./configure --prefix ${BOSH_INSTALL_TARGET}
16-
make
17-
make install
16+
make world
17+
make install-world

templates/jobs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
users:
3939
- porcupine
4040
- hedgehog
41+
extensions:
42+
- citext
43+
- pgcypto
4144
users:
4245
- username: porcupine
4346
password: quill

0 commit comments

Comments
 (0)