class MotionRecord::Schema::MigrationDefinition

Attributes

name[R]
version[R]

Public Class Methods

new(version, name = nil) click to toggle source
# File lib/motion_record/schema/migration_definition.rb, line 7
def initialize(version, name = nil)
  @version = version.to_i
  @name = name || "Migration ##{@version}"
  @definitions = []
end

Public Instance Methods

add_index(name, columns, options = {}) click to toggle source
# File lib/motion_record/schema/migration_definition.rb, line 27
def add_index(name, columns, options = {})
  @definitions << IndexDefinition.new(name, columns, options)
end
create_table(name, options = {}) { |table_definition| ... } click to toggle source
# File lib/motion_record/schema/migration_definition.rb, line 17
def create_table(name, options = {})
  table_definition = TableDefinition.new(name, options)

  if block_given?
    yield table_definition
  end

  @definitions << table_definition
end
execute() click to toggle source
# File lib/motion_record/schema/migration_definition.rb, line 13
def execute
  @definitions.each(&:execute)
end