#108 ✓resolved
Andreas Ronge


Reported by Andreas Ronge | February 8th, 2010 @ 11:32 AM | in 0.4.1

Should be easy to write migrations in order to keep code and database in sync.
For example, if we refactor a property that property has to be changed in the database as well.
Need to keep an version property on the RefNode.


Neo4j.migration 1, :create_articles do
    up do
      Neo4j.ref_node.articles << Articles.new :name => 'article name'
    down do        
      Neo4j.ref_node.articles.each {|r| r.del}         

Migrations can be used together with BatchInsert, see ticket #111

Lazy Migrations

Would be cool supporting lazy evaluation of migrations. The migration is only performed when the node is read.
Example let say that we split up the name property in two properties: surname and given_name

class Person
   include Neo4j::NodeMixin
   property :name

Changed to

class Person
   include Neo4j::NodeMixin
   property :surname, :given_name

The following migration will be called when a Person node is read and it does have a version property less then 1
It is evaluated in the context of the node that has been found needing to be upgraded/downgraded

Person.migration 1, :split_name do
  up do
    surname = self[:name].split[0]
    given_name = self[:name].split[1]

  down do
    name = "self[:given_name] #{self[:surname]}"

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Neo4j.rb is a graph database framework for JRuby.

It provides:

* Mapping of ruby objects to nodes in networks rather than in tables.
* Storage of ruby object to a file system.
* Fast traversal of relationships between nodes in a hugh node space.
* Transaction with rollbacks support.
* Indexing and quering of ruby objects.
* Integration with Rails

People watching this ticket

Referenced by