fix migration setting version too soon

neo4j-4
Josha von Gizycki 5 years ago
parent 73a8e5f2b9
commit 84a8c076a2

@ -16,15 +16,17 @@
:pw (hashers/derive pw) :pw (hashers/derive pw)
:uuid (neo4j/uuid)})) :uuid (neo4j/uuid)}))
(neo4j/defquery merge-config (neo4j/defquery init-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 = '' c.last_migration = ''")
ON MATCH SET
c.last_migration = {now}, (neo4j/defquery merge-config
c.db_version = {version}") "UPDATE (c:dbconfig)
SET c.last_migration = {now},
c.db_version = {version}")
(neo4j/defquery config (neo4j/defquery config
"MATCH (c:dbconfig) RETURN c") "MATCH (c:dbconfig) RETURN c")
@ -74,7 +76,7 @@
(neo4j/exec-query! ver-1-tag-uuid {})) (neo4j/exec-query! ver-1-tag-uuid {}))
(neo4j/defquery migrate-links (neo4j/defquery migrate-links
"MATCH (i1:instance)-[:link_from]-(l:link)-[:link_to]-(i2:instance), "MATCH (i1:instance)-[lf:link_from]-(l:link)-[lt:link_to]-(i2:instance),
(l)-[cb:created_by]->(:user) (l)-[cb:created_by]->(:user)
MERGE (i1)-[newl:link]->(i2) MERGE (i1)-[newl:link]->(i2)
ON CREATE SET ON CREATE SET
@ -92,8 +94,7 @@
init-version-2]) init-version-2])
(defn run-migrations! [] (defn run-migrations! []
(neo4j/exec-query! merge-config {:now (neo4j/now-str) (neo4j/exec-query! init-config {:now (neo4j/now-str)})
:version (count migrations)})
(let [version (-> (neo4j/exec-query! config {}) (let [version (-> (neo4j/exec-query! config {})
first first
:c :c

Loading…
Cancel
Save