Methods

Class/Module Index [+]

Quicksearch

Sequel::TimestampMigrator

The migrator used if any migration file version appears to be a timestamp. Stores filenames of migration files, and can figure out which migrations have not been applied and apply them, even if earlier migrations are added after later migrations. If you plan to do that, the responsibility is on you to make sure the migrations don’t conflict. Part of the migration extension.

Attributes

applied_migrations[R]

Array of strings of applied migration filenames

migration_tuples[R]

Get tuples of migrations, filenames, and actions for each migration

Public Class Methods

new(db, directory, opts={}) click to toggle source

Set up all state for the migrator instance

# File lib/sequel/extensions/migration.rb, line 422
def initialize(db, directory, opts={})
  super
  @target = opts[:target]
  @applied_migrations = get_applied_migrations
  @migration_tuples = get_migration_tuples
end

Public Instance Methods

run() click to toggle source

Apply all migration tuples on the database

# File lib/sequel/extensions/migration.rb, line 430
def run
  migration_tuples.each do |m, f, direction|
    t = Time.now
    db.log_info("Begin applying migration #{f}, direction: #{direction}")
    db.transaction do
      m.apply(db, direction)
      fi = f.downcase
      direction == :up ? ds.insert(column=>fi) : ds.filter(column=>fi).delete
    end
    db.log_info("Finished applying migration #{f}, direction: #{direction}, took #{sprintf('%0.6f', Time.now - t)} seconds")
  end
  nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.