Class | Sequel::Migration |
In: |
lib/sequel/extensions/migration.rb
|
Parent: | Object |
Sequel‘s older migration class, available for backward compatibility. Uses subclasses with up and down instance methods for each migration:
Class.new(Sequel::Migration) do def up create_table(:artists) do primary_key :id String :name end end def down drop_table(:artists) end end
Part of the migration extension.
Applies the migration to the supplied database in the specified direction.
# File lib/sequel/extensions/migration.rb, line 36 36: def self.apply(db, direction) 37: raise(ArgumentError, "Invalid migration direction specified (#{direction.inspect})") unless [:up, :down].include?(direction) 38: new(db).send(direction) 39: end
Returns the list of Migration descendants.
# File lib/sequel/extensions/migration.rb, line 42 42: def self.descendants 43: @descendants ||= [] 44: end
Adds the new migration class to the list of Migration descendants.
# File lib/sequel/extensions/migration.rb, line 47 47: def self.inherited(base) 48: descendants << base 49: end
Set the database associated with this migration.
# File lib/sequel/extensions/migration.rb, line 30 30: def initialize(db) 31: @db = db 32: end
Don‘t allow transaction overriding in old migrations.
# File lib/sequel/extensions/migration.rb, line 52 52: def self.use_transactions 53: nil 54: end
Intercepts method calls intended for the database and sends them along.
# File lib/sequel/extensions/migration.rb, line 61 61: def method_missing(method_sym, *args, &block) 62: @db.send(method_sym, *args, &block) 63: end