activegraph
activegraph copied to clipboard
Add a rake task for cleaning the database
This would be similar to db:reset
.
Could this be handled by wrapping database_cleaner which has support for Neo4j?
Runtime information:
Neo4j database version: neo4j gem version: 9.0.5 neo4j-core gem version: 7.7.2
Support for Neo4j was put into database_cleaner
, though database_cleaner
isn't really needed because there's currently only one way to delete things in Neo4j (that is, via the DELETE
clause. There are no truncate or viable transaction options in Neo4j. See this explination)
This would be a pretty easy task to create, though. It should be as simple as running:
Neo4j::ActiveBase.query('MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r')
Neo4j::Core::Label.drop_uniqueness_constraints_for(Neo4j::ActiveBase.current_session)
Neo4j::Core::Label.drop_indexes_for(Neo4j::ActiveBase.current_session)
Notice that I didn't do the DETACH DELETE
. By doing the OPTIONAL MATCH
/ DELETE
syntax, databases before 3.0 are supported.