class Sequel::Migration
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.
Public Class Methods
apply(db, direction)
click to toggle source
Applies the migration to the supplied database in the specified direction.
# File lib/sequel/extensions/migration.rb, line 42 def self.apply(db, direction) raise(ArgumentError, "Invalid migration direction specified (#{direction.inspect})") unless [:up, :down].include?(direction) new(db).send(direction) end
descendants()
click to toggle source
Returns the list of Migration descendants.
# File lib/sequel/extensions/migration.rb, line 48 def self.descendants @descendants ||= [] end
inherited(base)
click to toggle source
Adds the new migration class to the list of Migration descendants.
# File lib/sequel/extensions/migration.rb, line 53 def self.inherited(base) descendants << base end
new(db)
click to toggle source
Set the database associated with this migration.
# File lib/sequel/extensions/migration.rb, line 36 def initialize(db) @db = db end
use_transactions()
click to toggle source
Don't allow transaction overriding in old migrations.
# File lib/sequel/extensions/migration.rb, line 58 def self.use_transactions nil end
Public Instance Methods
down()
click to toggle source
The default down action does nothing
# File lib/sequel/extensions/migration.rb, line 63 def down end
method_missing(method_sym, *args, &block)
click to toggle source
Intercepts method calls intended for the database and sends them along.
# File lib/sequel/extensions/migration.rb, line 67 def method_missing(method_sym, *args, &block) @db.send(method_sym, *args, &block) end
respond_to_missing?(meth, include_private)
click to toggle source
This object responds to all methods the database responds to.
# File lib/sequel/extensions/migration.rb, line 72 def respond_to_missing?(meth, include_private) @db.respond_to?(meth, include_private) end
up()
click to toggle source
The default up action does nothing
# File lib/sequel/extensions/migration.rb, line 77 def up end