Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Provide example in readme and allow to pass single value without array

  • Loading branch information...
commit 5037954ce2663591ad3af8caa9e6a28d948573cc 1 parent 463f8de
@alno alno authored
Showing with 10 additions and 3 deletions.
  1. +8 −1 README.md
  2. +2 −2 definitions/pg_database_extensions.rb
View
9 README.md
@@ -39,7 +39,7 @@ The following platforms are supported by this cookbook, meaning that the recipes
This cookbook installs the postgresql components if not present, and pulls updates if they are installed on the system.
-Additionally this cookbook provides two definitions to create, alter and delete users as well as create and drop databases. Usage is as follows:
+Additionally this cookbook provides three definitions to create, alter and delete users as well as create and drop databases or setup extensions. Usage is as follows:
```ruby
@@ -68,6 +68,13 @@ pg_database "mydb" do
locale "en_US.UTF8"
end
+# install extensions to database
+pg_database_extensions "mydb" do
+ languages 'plpgsql' # instal plpgsql language - single value may be passed without array
+ extensions [ 'hstore', 'dblink' ] # install hstore and dblink extensions - multiple values in array
+ postgis true # install postgis support
+end
+
# drop a database
pg_database "mydb" do
action :drop
View
4 definitions/pg_database_extensions.rb
@@ -1,8 +1,8 @@
define :pg_database_extensions, :action => :create do
dbname = params[:name]
- languages = params[:languages] || []
- extensions = params[:extensions] || []
+ languages = [params[:languages] || []].flatten # Allow single value or array of values
+ extensions = [params[:extensions] || []].flatten
postgis = params[:postgis]
postgresql_version = node["postgresql"]["version"]
Please sign in to comment.
Something went wrong with that request. Please try again.