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.

Methods

Public Class methods

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

[Source]

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

Returns the list of Migration descendants.

[Source]

    # File lib/sequel/extensions/migration.rb, line 48
48:     def self.descendants
49:       @descendants ||= []
50:     end

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

[Source]

    # File lib/sequel/extensions/migration.rb, line 53
53:     def self.inherited(base)
54:       descendants << base
55:     end

Set the database associated with this migration.

[Source]

    # File lib/sequel/extensions/migration.rb, line 36
36:     def initialize(db)
37:       @db = db
38:     end

Don‘t allow transaction overriding in old migrations.

[Source]

    # File lib/sequel/extensions/migration.rb, line 58
58:     def self.use_transactions
59:       nil
60:     end

Public Instance methods

The default down action does nothing

[Source]

    # File lib/sequel/extensions/migration.rb, line 63
63:     def down
64:     end

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

[Source]

    # File lib/sequel/extensions/migration.rb, line 67
67:     def method_missing(method_sym, *args, &block)
68:       @db.send(method_sym, *args, &block)
69:     end

This object responds to all methods the database responds to.

[Source]

    # File lib/sequel/extensions/migration.rb, line 72
72:     def respond_to_missing?(meth, include_private)
73:       @db.respond_to?(meth, include_private)
74:     end

The default up action does nothing

[Source]

    # File lib/sequel/extensions/migration.rb, line 77
77:     def up
78:     end

[Validate]