/ env / dev / clj / user.clj
user.clj
 1  (ns user
 2    (:require [cat.config :refer [env]]
 3              [clojure.spec.alpha :as s]
 4              [expound.alpha :as expound]
 5              [mount.core :as mount]
 6              [cat.figwheel :refer [start-fw stop-fw cljs]]
 7              [cat.core :refer [start-app]]
 8              [cat.db.core]
 9              [conman.core :as conman]
10              [luminus-migrations.core :as migrations]))
11  
12  (alter-var-root #'s/*explain-out* (constantly expound/printer))
13  
14  (defn start []
15    (mount/start-without #'cat.core/repl-server))
16  
17  (defn stop []
18    (mount/stop-except #'cat.core/repl-server))
19  
20  (defn restart []
21    (stop)
22    (start))
23  
24  (defn restart-db []
25    (mount/stop #'cat.db.core/*db*)
26    (mount/start #'cat.db.core/*db*)
27    (binding [*ns* 'cat.db.core]
28      (conman/bind-connection cat.db.core/*db* "sql/queries.sql")))
29  
30  (defn reset-db []
31    (migrations/migrate ["reset"] (select-keys env [:database-url])))
32  
33  (defn migrate []
34    (migrations/migrate ["migrate"] (select-keys env [:database-url])))
35  
36  (defn rollback []
37    (migrations/migrate ["rollback"] (select-keys env [:database-url])))
38  
39  (defn create-migration [name]
40    (migrations/create name (select-keys env [:database-url])))
41  
42