Class: ActiveGraph::Migration::AddIdProperty
Instance Attribute Summary collapse
Instance Method Summary
collapse
#populate_id_property
#default_path, #joined_path, #output, #print_output
Constructor Details
#initialize(path = default_path) ⇒ AddIdProperty
Returns a new instance of AddIdProperty.
36
37
38
|
# File 'lib/active_graph/migration.rb', line 36
def initialize(path = default_path)
@models_filename = File.join(joined_path(path), 'add_id_property.yml')
end
|
Instance Attribute Details
#models_filename ⇒ Object
Returns the value of attribute models_filename.
34
35
36
|
# File 'lib/active_graph/migration.rb', line 34
def models_filename
@models_filename
end
|
Instance Method Details
#execute(*args) ⇒ Object
58
59
60
|
# File 'lib/active_graph/migration.rb', line 58
def execute(*args)
Base.query(*args)
end
|
#migrate ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/active_graph/migration.rb', line 40
def migrate
ActiveSupport::Deprecation.warn '`AddIdProperty` task is deprecated and may be removed from future releases. '\
'Create a new migration and use the `populate_id_property` helper.', caller
models = ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(models_filename))[:models]
output 'This task will add an ID Property every node in the given file.'
output 'It may take a significant amount of time, please be patient.'
models.each do |model|
output
output
output "Adding IDs to #{model}"
populate_id_property model
end
end
|
#query(*args) ⇒ Object
54
55
56
|
# File 'lib/active_graph/migration.rb', line 54
def query(*args)
Base.magic_query(*args)
end
|
#setup ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/active_graph/migration.rb', line 62
def setup
super
return if File.file?(models_filename)
File.open(models_filename, 'w') do |file|
message = <<MESSAGE
# Provide models to which IDs should be added.
# # It will only modify nodes that do not have IDs. There is no danger of overwriting data.
# # models: [Student,Lesson,Teacher,Exam]\nmodels: []
MESSAGE
file.write(message)
end
end
|