Is there a cypher command to drop all constraints?
I know I can drop specific constraints.
DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE
However I want to clear all constraints as part of teardown after testing. Can't find anything in the docs, but something like:
DROP CONSTRAINT *
Update: My testing setup.
Writing a tiny promise-based nodejs cypher client. I want to test defining unique indexes in application code.
The only way to drop constraints is doing this on a per-constraint level. You can use e.g.
:schema
in the Neo4j browser to get a list of all constraints. I'd just write a short script for this.Here is how I do this in Python:
Feels a bit icky, I feel like constraints should be a better supported thing.
Here is a helper for those using neo4jrb gem:
You can get a list of all indexes and constraints through GET requests to
http://localhost:7474/db/data/schema/constraint/
andhttp://localhost:7474/db/data/schema/index
. Here's how I do it in Ruby, maybe it'll give you an idea of how to do the same in Node.Note using APOC you can drop all indexes and constraints via
CALL apoc.schema.assert({}, {})
.