|
|
@ -1,10 +1,9 @@
|
|
|
|
(ns wanijo.infrastructure.repl
|
|
|
|
(ns wanijo.infrastructure.repl
|
|
|
|
(:require [buddy.hashers :as hashers]
|
|
|
|
(:require [buddy.hashers :as hashers]
|
|
|
|
[neo4j-clj.core :as db]
|
|
|
|
|
|
|
|
[wanijo.infrastructure.neo4j :as neo4j]
|
|
|
|
[wanijo.infrastructure.neo4j :as neo4j]
|
|
|
|
[wanijo.main :as main]))
|
|
|
|
[wanijo.main :as main]))
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery create-user
|
|
|
|
(neo4j/defquery create-user
|
|
|
|
"CREATE (n:user)
|
|
|
|
"CREATE (n:user)
|
|
|
|
SET n.ident = {ident}
|
|
|
|
SET n.ident = {ident}
|
|
|
|
SET n.pw = {pw}
|
|
|
|
SET n.pw = {pw}
|
|
|
@ -17,7 +16,7 @@
|
|
|
|
:pw (hashers/derive pw)
|
|
|
|
:pw (hashers/derive pw)
|
|
|
|
:uuid (neo4j/uuid)}))
|
|
|
|
:uuid (neo4j/uuid)}))
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery merge-config
|
|
|
|
(neo4j/defquery merge-config
|
|
|
|
"MERGE (c:dbconfig)
|
|
|
|
"MERGE (c:dbconfig)
|
|
|
|
ON CREATE SET
|
|
|
|
ON CREATE SET
|
|
|
|
c.installed_at = {now},
|
|
|
|
c.installed_at = {now},
|
|
|
@ -27,38 +26,38 @@
|
|
|
|
c.last_migration = {now},
|
|
|
|
c.last_migration = {now},
|
|
|
|
c.db_version = {version}")
|
|
|
|
c.db_version = {version}")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery config
|
|
|
|
(neo4j/defquery config
|
|
|
|
"MATCH (c:dbconfig) RETURN c")
|
|
|
|
"MATCH (c:dbconfig) RETURN c")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-schema-uuid
|
|
|
|
(neo4j/defquery ver-0-schema-uuid
|
|
|
|
"CREATE CONSTRAINT ON (n:schema)
|
|
|
|
"CREATE CONSTRAINT ON (n:schema)
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-attribute-uuid
|
|
|
|
(neo4j/defquery ver-0-attribute-uuid
|
|
|
|
"CREATE CONSTRAINT ON (n:attribute)
|
|
|
|
"CREATE CONSTRAINT ON (n:attribute)
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-instance-uuid
|
|
|
|
(neo4j/defquery ver-0-instance-uuid
|
|
|
|
"CREATE CONSTRAINT ON (n:instance)
|
|
|
|
"CREATE CONSTRAINT ON (n:instance)
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-property-uuid
|
|
|
|
(neo4j/defquery ver-0-property-uuid
|
|
|
|
"CREATE CONSTRAINT ON (n:property)
|
|
|
|
"CREATE CONSTRAINT ON (n:property)
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-user-uuid
|
|
|
|
(neo4j/defquery ver-0-user-uuid
|
|
|
|
"CREATE CONSTRAINT ON (n:user)
|
|
|
|
"CREATE CONSTRAINT ON (n:user)
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-link-uuid
|
|
|
|
(neo4j/defquery ver-0-link-uuid
|
|
|
|
"CREATE CONSTRAINT ON (n:link)
|
|
|
|
"CREATE CONSTRAINT ON (n:link)
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-1-tag-name
|
|
|
|
(neo4j/defquery ver-1-tag-name
|
|
|
|
"CREATE CONSTRAINT ON (n:tag)
|
|
|
|
"CREATE CONSTRAINT ON (n:tag)
|
|
|
|
ASSERT n.name IS UNIQUE")
|
|
|
|
ASSERT n.name IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-1-tag-uuid
|
|
|
|
(neo4j/defquery ver-1-tag-uuid
|
|
|
|
"CREATE CONSTRAINT ON (n:tag)
|
|
|
|
"CREATE CONSTRAINT ON (n:tag)
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
@ -74,9 +73,23 @@
|
|
|
|
(neo4j/exec-query! ver-1-tag-name {})
|
|
|
|
(neo4j/exec-query! ver-1-tag-name {})
|
|
|
|
(neo4j/exec-query! ver-1-tag-uuid {}))
|
|
|
|
(neo4j/exec-query! ver-1-tag-uuid {}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery migrate-links
|
|
|
|
|
|
|
|
"MATCH (i1:instance)-[:link_from]-(l:link)-[:link_to]-(i2:instance),
|
|
|
|
|
|
|
|
(l)-[cb:created_by]->(:user)
|
|
|
|
|
|
|
|
MERGE (i1)-[newl:link]->(i2)
|
|
|
|
|
|
|
|
ON CREATE SET
|
|
|
|
|
|
|
|
newl.name = l.name,
|
|
|
|
|
|
|
|
newl.created_at = l.created_at,
|
|
|
|
|
|
|
|
newl.uuid = l.uuid
|
|
|
|
|
|
|
|
DELETE cb, lf, lt, l")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn init-version-2 []
|
|
|
|
|
|
|
|
(neo4j/exec-query! migrate-links {}))
|
|
|
|
|
|
|
|
|
|
|
|
(def migrations
|
|
|
|
(def migrations
|
|
|
|
[init-version-0
|
|
|
|
[init-version-0
|
|
|
|
init-version-1])
|
|
|
|
init-version-1
|
|
|
|
|
|
|
|
init-version-2])
|
|
|
|
|
|
|
|
|
|
|
|
(defn run-migrations! []
|
|
|
|
(defn run-migrations! []
|
|
|
|
(neo4j/exec-query! merge-config {:now (neo4j/now-str)
|
|
|
|
(neo4j/exec-query! merge-config {:now (neo4j/now-str)
|
|
|
|