Class: Sequel::SimpleMigration
- 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
-
#down ⇒ Object
Proc used for the down action.
-
#up ⇒ Object
Proc used for the up action.
-
#use_transactions ⇒ Object
Whether to use transactions for this migration, default depends on the database.
Instance Method Summary collapse
-
#apply(db, direction) ⇒ Object
Apply the appropriate block on the
Database
instance using instance_eval. -
#initialize ⇒ SimpleMigration
constructor
Don’t set transaction use by default.
Constructor Details
#initialize ⇒ SimpleMigration
Don’t set transaction use by default.
97 98 99 |
# File 'lib/sequel/extensions/migration.rb', line 97 def initialize @use_transactions = nil end |
Instance Attribute Details
#down ⇒ Object
Proc used for the down action
87 88 89 |
# File 'lib/sequel/extensions/migration.rb', line 87 def down @down end |
#up ⇒ Object
Proc used for the up action
90 91 92 |
# File 'lib/sequel/extensions/migration.rb', line 90 def up @up end |
#use_transactions ⇒ Object
Whether to use transactions for this migration, default depends on the database.
94 95 96 |
# File 'lib/sequel/extensions/migration.rb', line 94 def use_transactions @use_transactions end |
Instance Method Details
#apply(db, direction) ⇒ Object
Apply the appropriate block on the Database
instance using instance_eval.
103 104 105 106 107 108 |
# File 'lib/sequel/extensions/migration.rb', line 103 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 |