Skip to content

Instantly share code, notes, and snippets.

@chrisbetz
Last active May 18, 2018 11:27
Show Gist options
  • Save chrisbetz/75433e9055b264410b5f3d0aa460f02d to your computer and use it in GitHub Desktop.
Save chrisbetz/75433e9055b264410b5f3d0aa460f02d to your computer and use it in GitHub Desktop.
(ns myproject.neo4j.migrations.20171024T112338Z-unique-org-unit-id
(:require [joplin.neo4j.database :refer [with-connection]]
[neo4j-clj.core :refer [defquery]]))
(defquery create-org-unit-id-exists-constraint
"CREATE CONSTRAINT ON (u:OrgUnit) ASSERT exists(u.id)")
(defquery drop-org-unit-id-exists-constraint
"DROP CONSTRAINT ON (u:OrgUnit) ASSERT exists(u.id)")
(defquery create-unique-org-unit-id-constraint
"CREATE CONSTRAINT ON (u:OrgUnit) ASSERT u.id IS UNIQUE")
(defquery drop-unique-org-unit-id-constraint
"DROP CONSTRAINT ON (u:OrgUnit) u.id IS UNIQUE")
(defn up [db]
(with-connection db session
(create-org-unit-id-exists-constraint session)
(create-unique-org-unit-id-constraint session)))
(defn down [db]
(with-connection db session
(drop-org-unit-id-exists-constraint session)
(drop-unique-org-unit-id-constraint session)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment