neo4j 1.0.0.beta.26-java → 1.0.0.beta.27-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/neo4j-shell +107 -0
- data/bin/neo4j-shell~ +108 -0
- data/config/locales/en.yml +5 -0
- data/config/neo4j/config.yml +89 -0
- data/lib/Gemfile~ +3 -0
- data/lib/config2.yml~ +86 -0
- data/lib/neo4j.rb +34 -8
- data/lib/neo4j/config.rb +41 -12
- data/lib/neo4j/database.rb +34 -13
- data/lib/neo4j/index/class_methods.rb +1 -1
- data/lib/neo4j/index/lucene_query.rb +4 -2
- data/lib/neo4j/jars/{geronimo-jta_1.1_spec-1.1.1.jar → core/geronimo-jta_1.1_spec-1.1.1.jar} +0 -0
- data/lib/neo4j/jars/{lucene-core-3.0.2.jar → core/lucene-core-3.0.3.jar} +0 -0
- data/lib/neo4j/jars/core/neo4j-graph-algo-0.8-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-index-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-kernel-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/core/neo4j-lucene-index-0.5-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/ha/log4j-1.2.16.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-ha-0.6-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-management-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/ha/neo4j-shell-1.3-SNAPSHOT.jar +0 -0
- data/lib/neo4j/jars/ha/netty-3.2.1.Final.jar +0 -0
- data/lib/neo4j/jars/ha/org.apache.servicemix.bundles.jline-0.9.94_1.jar +0 -0
- data/lib/neo4j/jars/ha/org.apache.servicemix.bundles.lucene-3.0.1_2.jar +0 -0
- data/lib/neo4j/jars/ha/zookeeper-3.3.2.jar +0 -0
- data/lib/neo4j/mapping/class_methods/relationship.rb +1 -2
- data/lib/neo4j/mapping/class_methods/rule.rb +35 -3
- data/lib/neo4j/mapping/decl_relationship_dsl.rb +1 -1
- data/lib/neo4j/mapping/has_n.rb +4 -1
- data/lib/neo4j/mapping/node_mixin.rb +1 -1
- data/lib/neo4j/mapping/rule.rb +9 -6
- data/lib/neo4j/mapping/rule_node.rb +0 -1
- data/lib/neo4j/migrations.rb +12 -0
- data/lib/neo4j/migrations/extensions.rb +57 -0
- data/lib/neo4j/migrations/global_migration.rb +29 -0
- data/lib/neo4j/migrations/lazy_migration_mixin.rb +47 -0
- data/lib/neo4j/migrations/migration.rb +109 -0
- data/lib/neo4j/migrations/migration_mixin.rb +78 -0
- data/lib/neo4j/migrations/migrations.rb +100 -0
- data/lib/neo4j/neo4j.rb +33 -9
- data/lib/neo4j/node_relationship.rb +2 -4
- data/lib/neo4j/node_traverser.rb +5 -0
- data/lib/neo4j/rails/finders.rb +10 -3
- data/lib/neo4j/rails/lucene_connection_closer.rb +1 -2
- data/lib/neo4j/rails/mapping/property.rb +1 -1
- data/lib/neo4j/rails/model.rb +1 -1
- data/lib/neo4j/rails/persistence.rb +1 -5
- data/lib/neo4j/rails/relationships/relationships.rb +13 -10
- data/lib/neo4j/version.rb +1 -1
- data/lib/perf.rb~ +36 -0
- data/neo4j.gemspec +4 -2
- metadata +40 -78
- data/lib/neo4j/jars/neo4j-graph-algo-0.7-1.2.jar +0 -0
- data/lib/neo4j/jars/neo4j-index-1.2-1.2.jar +0 -0
- data/lib/neo4j/jars/neo4j-kernel-1.2-1.2.jar +0 -0
- data/lib/neo4j/jars/neo4j-lucene-index-0.2-1.2.jar +0 -0
- data/lib/tmp/neo4j/active_tx_log +0 -1
- data/lib/tmp/neo4j/index.db +0 -0
- data/lib/tmp/neo4j/index/lucene-store.db +0 -0
- data/lib/tmp/neo4j/index/lucene.log.active +0 -0
- data/lib/tmp/neo4j/index/lucene/node/Network-exact/_0.cfs +0 -0
- data/lib/tmp/neo4j/index/lucene/node/Network-exact/segments.gen +0 -0
- data/lib/tmp/neo4j/index/lucene/node/Network-exact/segments_2 +0 -0
- data/lib/tmp/neo4j/lucene-fulltext/lucene-store.db +0 -0
- data/lib/tmp/neo4j/lucene-fulltext/lucene.log.active +0 -0
- data/lib/tmp/neo4j/lucene/lucene-store.db +0 -0
- data/lib/tmp/neo4j/lucene/lucene.log.active +0 -0
- data/lib/tmp/neo4j/messages.log +0 -85
- data/lib/tmp/neo4j/neostore +0 -0
- data/lib/tmp/neo4j/neostore.id +0 -0
- data/lib/tmp/neo4j/neostore.nodestore.db +0 -0
- data/lib/tmp/neo4j/neostore.nodestore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.arrays +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.arrays.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.keys +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.keys.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.strings +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.strings.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshipstore.db +0 -0
- data/lib/tmp/neo4j/neostore.relationshipstore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names.id +0 -0
- data/lib/tmp/neo4j/nioneo_logical.log.active +0 -0
- data/lib/tmp/neo4j/tm_tx_log.1 +0 -0
data/lib/neo4j/config.rb
CHANGED
@@ -17,22 +17,51 @@ module Neo4j
|
|
17
17
|
class Config
|
18
18
|
# This code is copied from merb-core/config.rb.
|
19
19
|
class << self
|
20
|
-
|
20
|
+
|
21
|
+
# The location of the default configuration file
|
22
|
+
def default_file
|
23
|
+
@default_file ||= File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config", "neo4j", "config.yml"))
|
24
|
+
end
|
25
|
+
|
26
|
+
# You can keep all the configuration in your own yaml file
|
27
|
+
# Also deletes all old configurations.
|
28
|
+
def default_file=(file_path)
|
29
|
+
@configuration = nil
|
30
|
+
@defaults = nil
|
31
|
+
@default_file = File.expand_path(file_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the hash of default config values for neo4j.
|
21
35
|
#
|
22
36
|
# ==== Returns
|
23
37
|
# Hash:: The defaults for the config.
|
24
38
|
def defaults
|
25
|
-
@defaults ||=
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
39
|
+
@defaults ||= YAML.load_file(default_file)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns a Java HashMap used by the Java Neo4j API as configuration for the GraphDatabase
|
43
|
+
def to_java_map
|
44
|
+
map = java.util.HashMap.new
|
45
|
+
to_hash.each_pair do |k, v|
|
46
|
+
case v
|
47
|
+
when TrueClass
|
48
|
+
map[k.to_s] = "YES"
|
49
|
+
when FalseClass
|
50
|
+
map[k.to_s] = "NO"
|
51
|
+
when String, Fixnum, Float
|
52
|
+
map[k.to_s] = v.to_s
|
53
|
+
# skip list and hash values - not accepted by the Java Neo4j API
|
54
|
+
end
|
55
|
+
end
|
56
|
+
map
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
# Returns the expanded path of the Config[:storage_path] property
|
61
|
+
def storage_path
|
62
|
+
File.expand_path(self[:storage_path])
|
33
63
|
end
|
34
64
|
|
35
|
-
|
36
65
|
# Yields the configuration.
|
37
66
|
#
|
38
67
|
# ==== Block parameters
|
@@ -116,7 +145,7 @@ module Neo4j
|
|
116
145
|
# The a new configuration using default values as a hash.
|
117
146
|
#
|
118
147
|
def setup()
|
119
|
-
@configuration =
|
148
|
+
@configuration = ActiveSupport::HashWithIndifferentAccess.new(defaults)
|
120
149
|
@configuration.merge!(defaults)
|
121
150
|
@configuration
|
122
151
|
end
|
@@ -128,7 +157,7 @@ module Neo4j
|
|
128
157
|
# The config as a hash.
|
129
158
|
#
|
130
159
|
def to_hash
|
131
|
-
@configuration
|
160
|
+
@configuration ||= setup
|
132
161
|
end
|
133
162
|
|
134
163
|
# Returns the config as YAML.
|
data/lib/neo4j/database.rb
CHANGED
@@ -16,25 +16,46 @@ module Neo4j
|
|
16
16
|
def start #:nodoc:
|
17
17
|
return if running?
|
18
18
|
@running = true
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
|
20
|
+
begin
|
21
|
+
if self.class.locked?
|
22
|
+
start_readonly_graph_db
|
23
|
+
elsif Neo4j::Config['ha.db']
|
24
|
+
start_ha_graph_db
|
25
|
+
Neo4j.migrate!
|
26
|
+
else
|
27
|
+
start_local_graph_db
|
28
|
+
Neo4j.migrate!
|
29
|
+
end
|
30
|
+
rescue
|
31
|
+
@running = false
|
32
|
+
raise
|
24
33
|
end
|
25
34
|
|
26
35
|
at_exit { shutdown }
|
27
36
|
end
|
28
37
|
|
29
38
|
def start_readonly_graph_db #:nodoc:
|
30
|
-
|
31
|
-
|
39
|
+
Neo4j.logger.info "Starting Neo4j in readonly mode since the #{Neo4j.config.storage_path} is locked"
|
40
|
+
Neo4j.load_local_jars
|
41
|
+
@graph = org.neo4j.kernel.EmbeddedReadOnlyGraphDatabase.new(Config[:storage_path], Config.to_java_map)
|
32
42
|
end
|
33
43
|
|
34
44
|
def start_local_graph_db #:nodoc:
|
35
|
-
|
45
|
+
Neo4j.logger.info "Starting local Neo4j using db #{Neo4j.config.storage_path}"
|
46
|
+
Neo4j.load_local_jars
|
47
|
+
@graph = org.neo4j.kernel.EmbeddedGraphDatabase.new(Neo4j.config.storage_path, Config.to_java_map)
|
48
|
+
@graph.register_transaction_event_handler(@event_handler)
|
49
|
+
@lucene = @graph.index
|
50
|
+
@event_handler.neo4j_started(self)
|
51
|
+
end
|
52
|
+
|
53
|
+
def start_ha_graph_db
|
54
|
+
Neo4j.logger.info "starting Neo4j in HA mode, machine id: #{Neo4j.config['ha.machine_id']} at #{Neo4j.config['ha.server']} db #{Neo4j.config.storage_path}"
|
55
|
+
Neo4j.load_ha_jars # those jars are only needed for the HighlyAvailableGraphDatabase
|
56
|
+
@graph = org.neo4j.kernel.HighlyAvailableGraphDatabase.new(Neo4j.config.storage_path, Neo4j.config.to_java_map)
|
36
57
|
@graph.register_transaction_event_handler(@event_handler)
|
37
|
-
@lucene =
|
58
|
+
@lucene = @graph.index #org.neo4j.index.impl.lucene.LuceneIndexProvider.new
|
38
59
|
@event_handler.neo4j_started(self)
|
39
60
|
end
|
40
61
|
|
@@ -50,7 +71,7 @@ module Neo4j
|
|
50
71
|
|
51
72
|
# check if the database is locked. A neo4j database is locked when there is running.
|
52
73
|
def self.locked?
|
53
|
-
lock_file = File.join(
|
74
|
+
lock_file = File.join(Neo4j.config.storage_path, 'neostore')
|
54
75
|
return false unless File.exist?(lock_file)
|
55
76
|
rfile = java.io.RandomAccessFile.new(lock_file, 'rw')
|
56
77
|
begin
|
@@ -61,14 +82,14 @@ module Neo4j
|
|
61
82
|
return false
|
62
83
|
end
|
63
84
|
end
|
64
|
-
|
85
|
+
|
65
86
|
def shutdown #:nodoc:
|
66
87
|
if @running
|
67
88
|
@graph.unregister_transaction_event_handler(@event_handler) unless read_only?
|
68
89
|
@event_handler.neo4j_shutdown(self)
|
69
90
|
@graph.shutdown
|
70
|
-
@graph
|
71
|
-
@lucene
|
91
|
+
@graph = nil
|
92
|
+
@lucene = nil
|
72
93
|
@running = false
|
73
94
|
end
|
74
95
|
|
@@ -99,7 +99,9 @@ module Neo4j
|
|
99
99
|
# Does simply loop all search items till the n'th is found.
|
100
100
|
#
|
101
101
|
def [](index)
|
102
|
-
|
102
|
+
i = 0
|
103
|
+
each{|x| return x if i == index; i += 1}
|
104
|
+
nil # out of index
|
103
105
|
end
|
104
106
|
|
105
107
|
# Returns the number of search hits
|
@@ -199,7 +201,7 @@ module Neo4j
|
|
199
201
|
and_query = org.apache.lucene.search.BooleanQuery.new
|
200
202
|
|
201
203
|
query.each_pair do |key, value|
|
202
|
-
type = @decl_props[key.to_sym] && @decl_props[key.to_sym][:type]
|
204
|
+
type = @decl_props && @decl_props[key.to_sym] && @decl_props[key.to_sym][:type]
|
203
205
|
if !type.nil? && type != String
|
204
206
|
if Range === value
|
205
207
|
and_query.add(range_query(key, value.first, value.last, true, !value.exclude_end?), org.apache.lucene.search.BooleanClause::Occur::MUST)
|
data/lib/neo4j/jars/{geronimo-jta_1.1_spec-1.1.1.jar → core/geronimo-jta_1.1_spec-1.1.1.jar}
RENAMED
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -72,14 +72,13 @@ module Neo4j::Mapping
|
|
72
72
|
end}, __FILE__, __LINE__)
|
73
73
|
|
74
74
|
module_eval(%Q{def #{rel_type}
|
75
|
-
#dsl = #{clazz}._decl_rels[:#{rel_type}]
|
76
75
|
dsl = _decl_rels_for(:#{rel_type})
|
77
76
|
dsl.single_node(self)
|
78
77
|
end}, __FILE__, __LINE__)
|
79
78
|
|
80
79
|
module_eval(%Q{def #{rel_type}_rel
|
80
|
+
# TODO - use the class variable instance since we don't want to use none persisted rails relationships
|
81
81
|
dsl = #{clazz}._decl_rels[:'#{rel_type.to_s}']
|
82
|
-
# dsl = _decl_rels_for(:#{rel_type})
|
83
82
|
dsl.single_relationship(self)
|
84
83
|
end}, __FILE__, __LINE__)
|
85
84
|
|
@@ -128,7 +128,7 @@ module Neo4j::Mapping
|
|
128
128
|
end
|
129
129
|
|
130
130
|
# This is typically used for RSpecs to clean up rule nodes created by the #rule method.
|
131
|
-
# It also remove the
|
131
|
+
# It also remove all the rule class methods.
|
132
132
|
def delete_rules
|
133
133
|
singelton = class << self;
|
134
134
|
self;
|
@@ -141,10 +141,42 @@ module Neo4j::Mapping
|
|
141
141
|
|
142
142
|
# Force to trigger the rules.
|
143
143
|
# You don't normally need that since it will be done automatically.
|
144
|
-
|
145
|
-
|
144
|
+
# This can be useful if you need to trigger rules on already existing nodes in the database.
|
145
|
+
# Can also be called from an migration.
|
146
|
+
#
|
147
|
+
def trigger_rules(node, *changes)
|
148
|
+
Neo4j::Mapping::Rule.trigger_rules(node, *changes)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Returns a proc that will call add method on the given function
|
152
|
+
# Can be used in migration to trigger rules on already existing nodes.
|
153
|
+
# Parameter function_id is default to '_classname' which means that
|
154
|
+
# the function 'reacts' on changes on the property '_classname'.
|
155
|
+
# That property changes only when a node is created or deleted.
|
156
|
+
# Function using function_id '_classname' is typically used for counting number of nodes of a class.
|
157
|
+
def add_function_for(rule_name, function_name_or_class, function_id = '_classname')
|
158
|
+
function_for(:add, rule_name, function_name_or_class, function_id)
|
159
|
+
end
|
160
|
+
|
161
|
+
# See #add_function_for
|
162
|
+
# Calls the delete method on the function.
|
163
|
+
def delete_function_for(rule_name, function_name_or_class, function_id = '_classname')
|
164
|
+
function_for(:delete, rule_name, function_name_or_class, function_id)
|
146
165
|
end
|
147
166
|
|
167
|
+
# Returns a proc that calls the given method on the given function.
|
168
|
+
def function_for(method, rule_name, function_name_or_class, function_id = '_classname')
|
169
|
+
function_name = function_name_or_class.is_a?(Symbol)? function_name_or_class : function_name_or_class.function_name
|
170
|
+
rule_node = Neo4j::Mapping::Rule.rule_node_for(self)
|
171
|
+
rule = rule_node.find_rule(rule_name)
|
172
|
+
rule_node_raw = rule_node.rule_node
|
173
|
+
|
174
|
+
function = rule_node.find_function(rule_name, function_name, function_id)
|
175
|
+
lambda do |node|
|
176
|
+
new_value = node[function_id]
|
177
|
+
function.send(method, rule.rule_name, rule_node_raw, new_value)
|
178
|
+
end
|
179
|
+
end
|
148
180
|
end
|
149
181
|
|
150
182
|
Neo4j.unstarted_db.event_handler.add(Neo4j::Mapping::Rule) unless Neo4j.read_only?
|
@@ -171,7 +171,7 @@ module Neo4j::Mapping
|
|
171
171
|
if other_class_dsl
|
172
172
|
@relationship = other_class_dsl.relationship_class
|
173
173
|
else
|
174
|
-
|
174
|
+
Neo4j.logger.warn "Unknown outgoing relationship #{args[1]} on #{@target_class}"
|
175
175
|
end
|
176
176
|
elsif (Symbol === args[0])
|
177
177
|
# handle unspecified (unprefixed) relationship, e.g. has_n(:known_by).from(:type)
|
data/lib/neo4j/mapping/has_n.rb
CHANGED
@@ -32,8 +32,11 @@ module Neo4j
|
|
32
32
|
|
33
33
|
alias_method :length, :size
|
34
34
|
|
35
|
+
|
35
36
|
def [](index)
|
36
|
-
|
37
|
+
i = 0
|
38
|
+
each{|x| return x if i == index; i += 1}
|
39
|
+
nil # out of index
|
37
40
|
end
|
38
41
|
|
39
42
|
# Pretend we are an array - this is neccessarly for Rails actionpack/actionview/formhelper to work with this
|
@@ -33,7 +33,7 @@ module Neo4j::Mapping
|
|
33
33
|
|
34
34
|
delegate :[]=, :[], :property?, :props, :attributes, :update, :neo_id, :id, :rels, :rel?, :to_param, :getId,
|
35
35
|
:rel, :del, :list?, :print, :print_sub, :outgoing, :incoming, :both, :expand, :get_property, :set_property,
|
36
|
-
:equal?, :eql?, :==, :exist?, :getRelationships, :getSingleRelationship, :_rels, :rel,
|
36
|
+
:equal?, :eql?, :==, :exist?, :getRelationships, :getSingleRelationship, :_rels, :rel, :wrapped_entity,
|
37
37
|
:to => :@_java_node, :allow_nil => true
|
38
38
|
|
39
39
|
|
data/lib/neo4j/mapping/rule.rb
CHANGED
@@ -15,7 +15,7 @@ module Neo4j::Mapping
|
|
15
15
|
@functions = props[:functions]
|
16
16
|
@triggers = [@triggers] if @triggers && !@triggers.respond_to?(:each)
|
17
17
|
@functions = [@functions] if @functions && !@functions.respond_to?(:each)
|
18
|
-
@filter = block
|
18
|
+
@filter = block
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_s
|
@@ -41,7 +41,9 @@ module Neo4j::Mapping
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def execute_filter(node)
|
44
|
-
if @filter.
|
44
|
+
if @filter.nil?
|
45
|
+
true
|
46
|
+
elsif @filter.arity != 1
|
45
47
|
node.wrapper.instance_eval(&@filter)
|
46
48
|
else
|
47
49
|
@filter.call(node)
|
@@ -54,9 +56,7 @@ module Neo4j::Mapping
|
|
54
56
|
|
55
57
|
class << self
|
56
58
|
def add(clazz, rule_name, props, &block)
|
57
|
-
|
58
|
-
@rule_nodes[clazz.to_s] ||= RuleNode.new(clazz)
|
59
|
-
rule_node = @rule_nodes[clazz.to_s]
|
59
|
+
rule_node = rule_node_for(clazz.to_s)
|
60
60
|
rule_node.remove_rule(rule_name) # remove any previously inherited rules
|
61
61
|
rule_node.add_rule(rule_name, props, &block)
|
62
62
|
end
|
@@ -67,7 +67,9 @@ module Neo4j::Mapping
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def rule_node_for(clazz)
|
70
|
-
|
70
|
+
return nil if clazz.nil?
|
71
|
+
@rule_nodes ||= {}
|
72
|
+
@rule_nodes[clazz.to_s] ||= RuleNode.new(clazz)
|
71
73
|
end
|
72
74
|
|
73
75
|
def inherit(parent_class, subclass)
|
@@ -90,6 +92,7 @@ module Neo4j::Mapping
|
|
90
92
|
|
91
93
|
def trigger_rules(node, *changes)
|
92
94
|
classname = node[:_classname]
|
95
|
+
return unless classname # there are no rules if there is not a :_classname property
|
93
96
|
rule_node = rule_node_for(classname)
|
94
97
|
rule_node.execute_rules(node, *changes)
|
95
98
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'neo4j/migrations/extensions'
|
2
|
+
require 'neo4j/migrations/lazy_migration_mixin'
|
3
|
+
require 'neo4j/migrations/migration'
|
4
|
+
require 'neo4j/migrations/migration_mixin'
|
5
|
+
require 'neo4j/migrations/migrations'
|
6
|
+
require 'neo4j/migrations/global_migration'
|
7
|
+
|
8
|
+
module Neo4j
|
9
|
+
module Migrations
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Neo4j
|
2
|
+
|
3
|
+
class << self
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
##
|
7
|
+
# Returns the current version of the database.
|
8
|
+
# This version has been set by running one or more migrations.
|
9
|
+
# The version is stored on the reference node, with property 'db_version'
|
10
|
+
# (It Delegates to the Reference Node)
|
11
|
+
#
|
12
|
+
# === See Also
|
13
|
+
# Neo4j::MigrationMixin#db_version
|
14
|
+
#
|
15
|
+
# :singleton-method: db_version
|
16
|
+
|
17
|
+
##
|
18
|
+
# Force Neo4j.rb to perform migrations
|
19
|
+
#
|
20
|
+
# === See Also
|
21
|
+
# Neo4j::MigrationMixin#migrate!
|
22
|
+
#
|
23
|
+
# :singleton-method: migrate!
|
24
|
+
|
25
|
+
##
|
26
|
+
# Specifies a single migration.
|
27
|
+
# The up and down methods are automatically wrapped in a transaction.
|
28
|
+
#
|
29
|
+
# === Example
|
30
|
+
#
|
31
|
+
# Neo4j.migration 1, :create_articles do
|
32
|
+
# up do
|
33
|
+
# Neo4j.ref_node.rels.outgoing(:colours) << Neo4j.Node.new(:colour => 'red') << Neo4j.Node.new(:colour => 'blue')
|
34
|
+
# end
|
35
|
+
# down do
|
36
|
+
# Neo4j.ref_node.rels.outgoing(:colours).each {|n| n.del }
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# === See Also
|
41
|
+
# Neo4j::MigrationMixin::ClassMethods#migration
|
42
|
+
#
|
43
|
+
# :singleton-method: migration
|
44
|
+
|
45
|
+
##
|
46
|
+
# Returns all migrations that has been defined.
|
47
|
+
#
|
48
|
+
# === See Also
|
49
|
+
# Neo4j::MigrationMixin::ClassMethods#migrations
|
50
|
+
#
|
51
|
+
# :singleton-method: migrations
|
52
|
+
|
53
|
+
|
54
|
+
def_delegators :'Neo4j::GlobalMigration', :db_version, :migrate!, :migrations, :migration
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|