Class: Sequel::SimpleMigration

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel/extensions/migration.rb

Overview

Migration class used by the Sequel.migration DSL, using instances for each migration, unlike the Migration class, which uses subclasses for each migration. Part of the migration extension.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#downObject

Proc used for the down action



66
67
68
# File 'lib/sequel/extensions/migration.rb', line 66

def down
  @down
end

#upObject

Proc used for the up action



69
70
71
# File 'lib/sequel/extensions/migration.rb', line 69

def up
  @up
end

Instance Method Details

#apply(db, direction) ⇒ Object

Apply the appropriate block on the Database instance using instance_eval.

Raises:

  • (ArgumentError)


73
74
75
76
77
78
# File 'lib/sequel/extensions/migration.rb', line 73

def apply(db, direction)
  raise(ArgumentError, "Invalid migration direction specified (#{direction.inspect})") unless [:up, :down].include?(direction)
  if prok = send(direction)
    db.instance_eval(&prok)
  end
end