Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
heroku db-spec -- the :sslmode/:ssl/:sslfactory trifecta were necessary for me to let my laptop connect to my remote heroku postgres db.
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
);
(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
You can’t perform that action at this time.