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)

Constructor Details

- (SimpleMigration) initialize

Don't set transaction use by default.



90
91
92
# File 'lib/sequel/extensions/migration.rb', line 90

def initialize
  @use_transactions = nil
end

Instance Attribute Details

- (Object) down

Proc used for the down action



80
81
82
# File 'lib/sequel/extensions/migration.rb', line 80

def down
  @down
end

- (Object) up

Proc used for the up action



83
84
85
# File 'lib/sequel/extensions/migration.rb', line 83

def up
  @up
end

- (Object) use_transactions

Whether to use transactions for this migration, default depends on the database.



87
88
89
# File 'lib/sequel/extensions/migration.rb', line 87

def use_transactions
  @use_transactions
end

Instance Method Details

- (Object) apply(db, direction)

Apply the appropriate block on the Database instance using instance_eval.

Raises:

  • (ArgumentError)


96
97
98
99
100
101
# File 'lib/sequel/extensions/migration.rb', line 96

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