|
|
@ -3,8 +3,7 @@
|
|
|
|
[neo4j-clj.core :as db]
|
|
|
|
[neo4j-clj.core :as db]
|
|
|
|
[wanijo.framework.neo4j :as neo4j]))
|
|
|
|
[wanijo.framework.neo4j :as neo4j]))
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery
|
|
|
|
(db/defquery create-user
|
|
|
|
create-user
|
|
|
|
|
|
|
|
"CREATE (n:user)
|
|
|
|
"CREATE (n:user)
|
|
|
|
SET n.ident = {ident}
|
|
|
|
SET n.ident = {ident}
|
|
|
|
SET n.pw = {pw}
|
|
|
|
SET n.pw = {pw}
|
|
|
@ -16,3 +15,57 @@
|
|
|
|
{:ident ident
|
|
|
|
{:ident ident
|
|
|
|
:pw (hashers/derive pw)
|
|
|
|
:pw (hashers/derive pw)
|
|
|
|
:uuid (neo4j/uuid)}))
|
|
|
|
:uuid (neo4j/uuid)}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery init-config
|
|
|
|
|
|
|
|
"MERGE (c:dbconfig)
|
|
|
|
|
|
|
|
ON CREATE SET
|
|
|
|
|
|
|
|
c.installed_at = {now},
|
|
|
|
|
|
|
|
c.db_version = 0")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery config
|
|
|
|
|
|
|
|
"MATCH (c:dbconfig) RETURN c")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-schema-uuid
|
|
|
|
|
|
|
|
"CREATE CONSTRAINT ON (n:schema)
|
|
|
|
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-attribute-uuid
|
|
|
|
|
|
|
|
"CREATE CONSTRAINT ON (n:attribute)
|
|
|
|
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-instance-uuid
|
|
|
|
|
|
|
|
"CREATE CONSTRAINT ON (n:instance)
|
|
|
|
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-property-uuid
|
|
|
|
|
|
|
|
"CREATE CONSTRAINT ON (n:property)
|
|
|
|
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-user-uuid
|
|
|
|
|
|
|
|
"CREATE CONSTRAINT ON (n:user)
|
|
|
|
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(db/defquery ver-0-link-uuid
|
|
|
|
|
|
|
|
"CREATE CONSTRAINT ON (n:link)
|
|
|
|
|
|
|
|
ASSERT n.uuid IS UNIQUE")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn init-version-0 []
|
|
|
|
|
|
|
|
(neo4j/exec-query! ver-0-schema-uuid {})
|
|
|
|
|
|
|
|
(neo4j/exec-query! ver-0-attribute-uuid {})
|
|
|
|
|
|
|
|
(neo4j/exec-query! ver-0-instance-uuid {})
|
|
|
|
|
|
|
|
(neo4j/exec-query! ver-0-property-uuid {})
|
|
|
|
|
|
|
|
(neo4j/exec-query! ver-0-user-uuid {})
|
|
|
|
|
|
|
|
(neo4j/exec-query! ver-0-link-uuid {}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(def migrations
|
|
|
|
|
|
|
|
[init-version-0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn run-migrations! []
|
|
|
|
|
|
|
|
(neo4j/exec-query! init-config {:now (neo4j/now-str)})
|
|
|
|
|
|
|
|
(let [version (-> (neo4j/exec-query! config {})
|
|
|
|
|
|
|
|
first
|
|
|
|
|
|
|
|
:c
|
|
|
|
|
|
|
|
:db_version)]
|
|
|
|
|
|
|
|
(if-let [to-run (nthrest migrations version)]
|
|
|
|
|
|
|
|
(doseq [mig to-run]
|
|
|
|
|
|
|
|
(mig)))))
|
|
|
|