class ActiveGraph::Migration::AddIdProperty

Attributes

models_filename[R]

Public Class Methods

new(path = default_path) click to toggle source
   # File lib/active_graph/migration.rb
39 def initialize(path = default_path)
40   @models_filename = File.join(joined_path(path), 'add_id_property.yml')
41 end

Public Instance Methods

execute(*args) click to toggle source
   # File lib/active_graph/migration.rb
61 def execute(*args)
62   Base.query(*args)
63 end
migrate() click to toggle source
   # File lib/active_graph/migration.rb
43 def migrate
44   ActiveSupport::Deprecation.warn '`AddIdProperty` task is deprecated and may be removed from future releases. '\
45                                   'Create a new migration and use the `populate_id_property` helper.', caller
46   models = ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(models_filename))[:models]
47   output 'This task will add an ID Property every node in the given file.'
48   output 'It may take a significant amount of time, please be patient.'
49   models.each do |model|
50     output
51     output
52     output "Adding IDs to #{model}"
53     populate_id_property model
54   end
55 end
query(*args) click to toggle source
   # File lib/active_graph/migration.rb
57 def query(*args)
58   Base.magic_query(*args)
59 end
setup() click to toggle source
Calls superclass method ActiveGraph::Migration#setup
   # File lib/active_graph/migration.rb
65       def setup
66         super
67         return if File.file?(models_filename)
68 
69         File.open(models_filename, 'w') do |file|
70           message = <<MESSAGE
71 # Provide models to which IDs should be added.
72 # # It will only modify nodes that do not have IDs. There is no danger of overwriting data.
73 # # models: [Student,Lesson,Teacher,Exam]\nmodels: []
74 MESSAGE
75           file.write(message)
76         end
77       end