Skip to content
Snippets Groups Projects
Commit 14d6a93f authored by Ryan Senior's avatar Ryan Senior
Browse files

Switch from the PostgreSQL driver to Redshift

Previously we were using the PostgreSQL driver for connecting to
Redshift. Newer versions of PostgreSQL require newer drivers that are
no longer compatible with Redshift which has prevented us from
upgrading. By switching to the AWS Redshift driver, we can upgrade the
PostgreSQL driver independently.
parent 5d3dba23
No related branches found
No related tags found
No related merge requests found
......@@ -91,8 +91,10 @@
[ring/ring-json "0.4.0"] ; Ring middleware for reading/writing JSON automatically
[stencil "0.5.0"] ; Mustache templates for Clojure
[toucan "1.0.3" ; Model layer, hydration, and DB utilities
:exclusions [honeysql]]]
:repositories [["bintray" "https://dl.bintray.com/crate/crate"]] ; Repo for Crate JDBC driver
:exclusions [honeysql]]
[com.amazon.redshift/redshift-jdbc41 "1.2.8.1005"]] ; Redshift JDBC driver
:repositories [["bintray" "https://dl.bintray.com/crate/crate"]
["redshift" "http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release"]] ; Repo for Crate JDBC driver
:plugins [[lein-environ "1.1.0"] ; easy access to environment variables
[lein-ring "0.11.0" ; start the HTTP server with 'lein ring server'
:exclusions [org.clojure/clojure]]] ; TODO - should this be a dev dependency ?
......
......@@ -38,3 +38,15 @@
:subname (str "//" host ":" port "/" db)
:delimiters "`"}
(dissoc opts :host :port :db)))
(defn redshift
"Create a database specification for a redshift database. Opts should include
keys for :db, :user, and :password. You can also optionally set host and
port."
[{:keys [host port db]
:as opts}]
(merge {:classname "com.amazon.redshift.jdbc.Driver" ; must be in classpath
:subprotocol "redshift"
:subname (str "//" host ":" port "/" db)
:ssl true}
(dissoc opts :host :port :db)))
......@@ -16,7 +16,7 @@
[ssh :as ssh]]))
(defn- connection-details->spec [details]
(dbspec/postgres (merge details postgres/ssl-params))) ; always connect to redshift over SSL
(dbspec/redshift details))
(defn- date-interval [unit amount]
(hsql/call :+ :%getdate (hsql/raw (format "INTERVAL '%d %s'" (int amount) (name unit)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment