Last active
August 29, 2015 14:02
-
-
Save danneu/c3d1b15d0b977ee3a154 to your computer and use it in GitHub Desktop.
heroku db-spec -- the :sslmode/:ssl/:sslfactory trifecta were necessary for me to let my laptop connect to my remote heroku postgres db.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS users CASCADE; | |
CREATE TABLE users ( | |
id serial PRIMARY KEY, | |
uname text NOT NULL UNIQUE, | |
digest text NOT NULL, | |
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns xxx.db | |
(:require | |
[clojure.java.jdbc :as j] | |
[clojure.java.io :as io] | |
[clojure.string :as str] | |
[environ.core :as environ])) | |
(def db-spec {:classname "org.postgresql.Driver" | |
:subprotocol "postgresql" | |
:subname "//ec2-XX-XXX-XXX-XX.compute-1.amazonaws.com:5432/dbname" | |
:user "xxxxx" | |
:password "xxxxxxxxxxxx" | |
:sslmode "require" | |
:ssl true | |
:sslfactory (when-not (:production environ/env) | |
"org.postgresql.ssl.NonValidatingFactory")}) | |
(defn reset-db! [] | |
(j/execute! db-spec [(slurp (io/resource "sql/migrations/0-reset-and-init-db.sql"))])) | |
(reset-db!) ;=> [0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment