lib/lhm.rb in lhm-1.0.0.rc6 vs lib/lhm.rb in lhm-1.0.0.rc7
- old
+ new
@@ -15,28 +15,28 @@
# m.add_index([:arbitrary, :created_at])
# m.ddl("alter table %s add column flag tinyint(1)" % m.name)
# end
#
module Lhm
- extend self
# Alters a table with the changes described in the block
#
# @param [String, Symbol] table_name Name of the table
# @param [Hash] chunk_options Optional options to alter the chunk behavior
# @option chunk_options [Fixnum] :stride
# Size of a chunk (defaults to: 40,000)
# @option chunk_options [Fixnum] :throttle
# Time to wait between chunks in milliseconds (defaults to: 100)
# @yield [Migrator] Yielded Migrator object records the changes
- # @return [Boolean] Returns true if the migration finishs
+ # @return [Boolean] Returns true if the migration finishes
# @raise [Error] Raises Lhm::Error in case of a error and aborts the migration
- def change_table(table_name, chunk_options = {}, &block)
+ def self.change_table(table_name, chunk_options = {}, &block)
connection = ActiveRecord::Base.connection
origin = Table.parse(table_name, connection)
invoker = Invoker.new(origin, connection)
block.call(invoker.migrator)
invoker.run(chunk_options)
true
end
end
+