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

The migrator used if any migration file version is greater than 20000101. 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.

Methods

is_current?   new   run  

Constants

Error = Migrator::Error

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

Set up all state for the migrator instance

[Source]

     # File lib/sequel/extensions/migration.rb, line 670
670:     def initialize(db, directory, opts=OPTS)
671:       super
672:       @target = opts[:target]
673:       @applied_migrations = get_applied_migrations
674:       @migration_tuples = get_migration_tuples
675:     end

Public Instance methods

The timestamp migrator is current if there are no migrations to apply in either direction.

[Source]

     # File lib/sequel/extensions/migration.rb, line 679
679:     def is_current?
680:       migration_tuples.empty?
681:     end

Apply all migration tuples on the database

[Source]

     # File lib/sequel/extensions/migration.rb, line 684
684:     def run
685:       migration_tuples.each do |m, f, direction|
686:         t = Time.now
687:         db.log_info("Begin applying migration #{f}, direction: #{direction}")
688:         checked_transaction(m) do
689:           m.apply(db, direction)
690:           fi = f.downcase
691:           direction == :up ? ds.insert(column=>fi) : ds.where(column=>fi).delete
692:         end
693:         db.log_info("Finished applying migration #{f}, direction: #{direction}, took #{sprintf('%0.6f', Time.now - t)} seconds")
694:       end
695:       nil
696:     end

[Validate]