diff --git a/src/wanijo/infrastructure/repl.clj b/src/wanijo/infrastructure/repl.clj index 6e7a3cb..d0572a2 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