From ed03018d4d009101015f08d2cc1a569254a21937 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Mon, 27 Apr 2020 21:18:42 +0200 Subject: [PATCH] fix migration setting version too soon --- src/wanijo/infrastructure/repl.clj | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/wanijo/infrastructure/repl.clj b/src/wanijo/infrastructure/repl.clj index 10a83ef..451ba06 100644 --- a/src/wanijo/infrastructure/repl.clj +++ b/src/wanijo/infrastructure/repl.clj @@ -16,15 +16,17 @@ :pw (hashers/derive pw) :uuid (neo4j/uuid)})) -(neo4j/defquery merge-config +(neo4j/defquery init-config "MERGE (c:dbconfig) ON CREATE SET c.installed_at = {now}, c.db_version = 0, - c.last_migration = '' - ON MATCH SET - c.last_migration = {now}, - c.db_version = {version}") + c.last_migration = ''") + +(neo4j/defquery merge-config + "UPDATE (c:dbconfig) + SET c.last_migration = {now}, + c.db_version = {version}") (neo4j/defquery config "MATCH (c:dbconfig) RETURN c") @@ -74,7 +76,7 @@ (neo4j/exec-query! ver-1-tag-uuid {})) (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) MERGE (i1)-[newl:link]->(i2) ON CREATE SET @@ -92,8 +94,7 @@ init-version-2]) (defn run-migrations! [] - (neo4j/exec-query! merge-config {:now (neo4j/now-str) - :version (count migrations)}) + (neo4j/exec-query! init-config {:now (neo4j/now-str)}) (let [version (-> (neo4j/exec-query! config {}) first :c