Skip to content

Instantly share code, notes, and snippets.

@davidsantiago
Created November 1, 2010 17:13
Show Gist options
  • Save davidsantiago/658517 to your computer and use it in GitHub Desktop.
Save davidsantiago/658517 to your computer and use it in GitHub Desktop.
(defn ensure-database-exists
[request db-name & rest]
(-> request
(resource-when/resource-when
(= 0 @(psql "-t -c"
~(format "\"select count(1) from pg_database where datname='%s'\""
db-name)))
(apply create-database request db-name rest))))
;; Throws a stack trace complaining about too many args (5) to PersistentHashMap.
;; It will compile with the apply removed, but that is obviously wrong.
;; I cannot make it in any way do an if statement in the generated shell script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment