Last active
May 18, 2018 11:27
-
-
Save chrisbetz/75433e9055b264410b5f3d0aa460f02d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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