class Sequel::Migration

  1. lib/sequel/extensions/migration.rb
Superclass: 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.

Public Class methods

apply(db, direction)

Applies the migration to the supplied database in the specified direction.

[show source]
   # File lib/sequel/extensions/migration.rb
42 def self.apply(db, direction)
43   raise(ArgumentError, "Invalid migration direction specified (#{direction.inspect})") unless [:up, :down].include?(direction)
44   new(db).public_send(direction)
45 end
descendants()

Returns the list of Migration descendants.

[show source]
   # File lib/sequel/extensions/migration.rb
48 def self.descendants
49   @descendants ||= []
50 end
inherited(base)

Adds the new migration class to the list of Migration descendants.

[show source]
   # File lib/sequel/extensions/migration.rb
53 def self.inherited(base)
54   descendants << base
55 end
new(db)

Set the database associated with this migration.

[show source]
   # File lib/sequel/extensions/migration.rb
36 def initialize(db)
37   @db = db
38 end
use_transactions()

Don’t allow transaction overriding in old migrations.

[show source]
   # File lib/sequel/extensions/migration.rb
58 def self.use_transactions
59   nil
60 end

Public Instance methods

down()

The default down action does nothing

[show source]
   # File lib/sequel/extensions/migration.rb
63 def down
64 end
method_missing(method_sym, *args, &block)

Intercepts method calls intended for the database and sends them along.

[show source]
   # File lib/sequel/extensions/migration.rb
67 def method_missing(method_sym, *args, &block)
68   # Allow calling private methods for backwards compatibility
69   @db.send(method_sym, *args, &block)
70 end
respond_to_missing?(meth, include_private)

This object responds to all methods the database responds to.

[show source]
   # File lib/sequel/extensions/migration.rb
76 def respond_to_missing?(meth, include_private)
77   @db.respond_to?(meth, include_private)
78 end
up()

The default up action does nothing

[show source]
   # File lib/sequel/extensions/migration.rb
81 def up
82 end