Class Sequel::IntegerMigrator
In: lib/sequel/extensions/migration.rb
Parent: Migrator

The default migrator, recommended in most cases. Uses a simple incrementing version number starting with 1, where missing or duplicate migration file versions are not allowed. Part of the migration extension.

Methods

new   run  

Constants

DEFAULT_SCHEMA_COLUMN = :version
DEFAULT_SCHEMA_TABLE = :schema_info
Error = Migrator::Error

Attributes

current  [R]  The current version for this migrator
direction  [R]  The direction of the migrator, either :up or :down
migrations  [R]  The migrations used by this migrator

Public Class methods

Set up all state for the migrator instance

[Source]

     # File lib/sequel/extensions/migration.rb, line 420
420:     def initialize(db, directory, opts={})
421:       super
422:       @target = opts[:target] || latest_migration_version
423:       @current = opts[:current] || current_migration_version
424: 
425:       raise(Error, "No current version available") unless current
426:       raise(Error, "No target version available") unless target
427: 
428:       @direction = current < target ? :up : :down
429:       @migrations = get_migrations
430:     end

Public Instance methods

Apply all migrations on the database

[Source]

     # File lib/sequel/extensions/migration.rb, line 433
433:     def run
434:       migrations.zip(version_numbers).each do |m, v|
435:         t = Time.now
436:         lv = up? ? v : v + 1
437:         db.log_info("Begin applying migration version #{lv}, direction: #{direction}")
438:         db.transaction do
439:           m.apply(db, direction)
440:           set_migration_version(v)
441:         end
442:         db.log_info("Finished applying migration version #{lv}, direction: #{direction}, took #{sprintf('%0.6f', Time.now - t)} seconds")
443:       end
444:       
445:       target
446:     end

[Validate]