-
Notifications
You must be signed in to change notification settings - Fork 276
Neo4j v3 Migrations
The following documents pre-rerelease features. Documentation is being added ahead of time so it doesn't slip through the cracks after merge.
Migrations are an easy way to make database-wide changes. Unlike ActiveRecord, Neo4j.rb does not (yet?) keep track of migrations to run during a new deployment; rather, it offers a process for performing one-time or scheduled tasks as needed.
Usage is simple.
Include require 'neo4j/tasks/rails' in your Rakefile.
To run, rake neo4j:migrate[task_name,subtask]
Gem-provided migrations are found in neo4j/migration.rb
but if you have a custom task, put it in /db/neo4j-migrate/
and name it to match your task name. The contents of your file should be the classified version of the task name: task add_id_property
would have file add_id_property.rb
and contain class AddIdProperty
.
In the file, your class must inherit from Neo4j::Migration
and contain a migrate
method, to be executed when no subtask is provided at the command line. As an example rake neo4j:migrate[add_id_property]
is essentially equivalent to Neo4j::Migration::AddIdProperty.new.migrate
.
If you have other tasks that may be helpful, such as setup, define those as instance methods in your class and call from command line as rake neo4j:migrate[your_task,extra_method]
.
To use, run rake neo4j:migrate[add_id_property,setup]
and modify add_id_property.yml
, created in your Rails app's db/neo4j-migrate/
folder. It contains one line, models = []
. Add the names of models that need IDs generated to that array.
models = [Student,Lesson,Exam]
rake neo4j:migrate[add_id_property]
to execute. It will load the model, find its given ID property and generation method, and populate that property on all nodes of that class where an ID is not already assigned. It does this in batches of up to 900 at a time.
WARNING: Much of the information in this wiki is out of date. We are in the process of moving things to readthedocs
- Project Introduction
- Neo4j::ActiveNode
- Neo4j::ActiveRel
- Search and Scope
- Validation, Uniqueness, and Case Sensitivity
- Indexing VS Legacy Indexing
- Optimized Methods
- Inheritance
- Core: Nodes & Rels
- Introduction
- Persistence
- Find : Lucene
- Relationships
- Third Party Gems & extensions
- Scaffolding & Generators
- HA Cluster