mirror of
https://github.com/status-im/open-bounty.git
synced 2025-01-11 10:06:20 +00:00
Run pending DB migrations at startup
Run pending DB migrations at startup to make deployement simpler (eliminates need to clone repo and run "lein migratus migrate" on the server)
This commit is contained in:
parent
d39ccd1531
commit
1c26d17ad9
@ -4,7 +4,8 @@
|
||||
[clojure.java.jdbc :as jdbc]
|
||||
[conman.core :as conman]
|
||||
[commiteth.config :refer [env]]
|
||||
[mount.core :refer [defstate]])
|
||||
[mount.core :refer [defstate]]
|
||||
[migratus.core :as migratus])
|
||||
(:import org.postgresql.util.PGobject
|
||||
java.sql.Array
|
||||
clojure.lang.IPersistentMap
|
||||
@ -15,8 +16,18 @@
|
||||
Timestamp
|
||||
PreparedStatement]))
|
||||
|
||||
|
||||
(defn start []
|
||||
(let [db (env :jdbc-database-url)
|
||||
migratus-config {:store :database
|
||||
:migration-dir "migrations/"
|
||||
:migration-table-name "schema_migrations"
|
||||
:db db}]
|
||||
(migratus/migrate migratus-config)
|
||||
(conman/connect! {:jdbc-url db})))
|
||||
|
||||
(defstate ^:dynamic *db*
|
||||
:start (conman/connect! {:jdbc-url (env :jdbc-database-url)})
|
||||
:start (start)
|
||||
:stop (conman/disconnect! *db*))
|
||||
|
||||
(conman/bind-connection *db* "sql/queries.sql")
|
||||
|
Loading…
x
Reference in New Issue
Block a user