Compare commits

..

3 Commits

Author SHA1 Message Date
Josha von Gizycki 6f18bfe7f8 Merge branch 'master' of https://gitea.heevyis.ninja/josha/wanijo
5 years ago
Josha von Gizycki 913653780c ancient
5 years ago
Josha von Gizycki b69471fd98 fix migrations
5 years ago

@ -11,7 +11,7 @@
;; static site ;; static site
[compojure "1.6.1"] [compojure "1.6.1"]
[ring/ring-defaults "0.3.2"] [ring/ring-defaults "0.3.2"]
[ring/ring-jetty-adapter "1.7.1" [ring/ring-jetty-adapter "1.8.0"
:exclusions [ring/ring-core :exclusions [ring/ring-core
ring/ring-codec ring/ring-codec
commons-io commons-io
@ -23,7 +23,7 @@
;; compojure uses old transitive dependencies of ring ;; compojure uses old transitive dependencies of ring
;; specifiy them here explicitly so newer versions ;; specifiy them here explicitly so newer versions
;; will be used ;; will be used
[ring/ring-core "1.7.1"] [ring/ring-core "1.8.0"]
[ring/ring-codec "1.1.2"] [ring/ring-codec "1.1.2"]
;; neo4j ;; neo4j
@ -36,7 +36,7 @@
[buddy/buddy-hashers "1.4.0" [buddy/buddy-hashers "1.4.0"
:exclusions [commons-codec]] :exclusions [commons-codec]]
[clj-time "0.15.2"] [clj-time "0.15.2"]
[markdown-clj "1.10.0"] [markdown-clj "1.10.1"]
[dorothy "0.0.7"]] [dorothy "0.0.7"]]
:profiles {:dev {:plugins [;; neo4j db :profiles {:dev {:plugins [;; neo4j db
@ -50,7 +50,6 @@
[jonase/eastwood "LATEST"] [jonase/eastwood "LATEST"]
[lein-bikeshed "LATEST"] [lein-bikeshed "LATEST"]
[lein-cloverage "LATEST"] [lein-cloverage "LATEST"]
[cider/cider-nrepl "0.22.2"]
[lein-kibit "LATEST"]]} [lein-kibit "LATEST"]]}
:uberjar {:aot :all :uberjar {:aot :all
:main wanijo.main}} :main wanijo.main}}

@ -16,11 +16,15 @@
:pw (hashers/derive pw) :pw (hashers/derive pw)
:uuid (neo4j/uuid)})) :uuid (neo4j/uuid)}))
(db/defquery init-config (db/defquery merge-config
"MERGE (c:dbconfig) "MERGE (c:dbconfig)
ON CREATE SET ON CREATE SET
c.installed_at = {now}, c.installed_at = {now},
c.db_version = 0") c.db_version = 0,
c.last_migration = ''
ON MATCH SET
c.last_migration = {now},
c.db_version = {version}")
(db/defquery config (db/defquery config
"MATCH (c:dbconfig) RETURN c") "MATCH (c:dbconfig) RETURN c")
@ -74,11 +78,18 @@
init-version-1]) init-version-1])
(defn run-migrations! [] (defn run-migrations! []
(neo4j/exec-query! init-config {:now (neo4j/now-str)}) (neo4j/exec-query! merge-config {:now (neo4j/now-str)
:version (count migrations)})
(let [version (-> (neo4j/exec-query! config {}) (let [version (-> (neo4j/exec-query! config {})
first first
:c :c
:db_version)] :db_version)]
(if-let [to-run (nthrest migrations version)] (println "got version" version "from db," (count migrations) "available")
(when-let [to-run (nthrest migrations version)]
(println "running" (count to-run) "migrations")
(doseq [mig to-run] (doseq [mig to-run]
(mig))))) (println "running" mig)
(mig))))
(neo4j/exec-query! merge-config {:now (neo4j/now-str)
:version (count migrations)})
nil)

Loading…
Cancel
Save