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

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.

Methods

new   run  

Constants

DEFAULT_SCHEMA_COLUMN = :filename
DEFAULT_SCHEMA_TABLE = :schema_migrations
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 540
540:     def initialize(db, directory, opts={})
541:       super
542:       @target = opts[:target]
543:       @applied_migrations = get_applied_migrations
544:       @migration_tuples = get_migration_tuples
545:     end

Public Instance methods

Apply all migration tuples on the database

[Source]

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

[Validate]