|
|
@ -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)
|
|
|
|