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

apply descendants down inherited method_missing new up use_transactions

### Public Class methods

apply(db, direction)

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

[Source]

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

descendants()

Returns the list of Migration descendants.

[Source]

        # File lib/sequel/extensions/migration.rb, line 41
    41:     def self.descendants
    42:       @descendants ||= []
    43:     end

inherited(base)

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

[Source]

        # File lib/sequel/extensions/migration.rb, line 46
    46:     def self.inherited(base)
    47:       descendants << base
    48:     end

new(db)

Set the database associated with this migration.

[Source]

        # File lib/sequel/extensions/migration.rb, line 29
    29:     def initialize(db)
    30:       @db = db
    31:     end

use_transactions()

Don‘t allow transaction overriding in old migrations.

[Source]

        # File lib/sequel/extensions/migration.rb, line 51
    51:     def self.use_transactions
    52:       nil
    53:     end

### Public Instance methods

down()

The default down action does nothing

[Source]

        # File lib/sequel/extensions/migration.rb, line 56
    56:     def down
    57:     end

method_missing(method_sym, *args, &block)

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

[Source]

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

up()

The default up action does nothing

[Source]

        # File lib/sequel/extensions/migration.rb, line 65
    65:     def up
    66:     end

[Validate]