Compare commits

...

3 Commits

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

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

@ -16,11 +16,15 @@
:pw (hashers/derive pw)
:uuid (neo4j/uuid)}))
(db/defquery init-config
(db/defquery merge-config
"MERGE (c:dbconfig)
ON CREATE SET
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
"MATCH (c:dbconfig) RETURN c")
@ -74,11 +78,18 @@
init-version-1])
(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 {})
first
:c
: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]
(mig)))))
(println "running" mig)
(mig))))
(neo4j/exec-query! merge-config {:now (neo4j/now-str)
:version (count migrations)})
nil)

Loading…
Cancel
Save