Module: ROM::SQL::Migration::SequelExtension::MigratorClassSelector Private

Defined in:
lib/sequel/extensions/sql_migrations.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Prepended into Sequel::Migrator's singleton class. Replaces the migrator_class selector so the extension-aware pattern is used when sniffing the directory for integer-vs-timestamp selection.

Instance Method Summary collapse

Instance Method Details

#migrator_class(directory) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/sequel/extensions/sql_migrations.rb', line 53

def migrator_class(directory)
  if equal?(Sequel::Migrator)
    raise Sequel::Migrator::Error, "Must supply a valid migration path" unless File.directory?(directory)

    Dir.new(directory).each do |file|
      next unless MIGRATION_FILE_PATTERN.match(file)
      return Sequel::TimestampMigrator if file.split("_", 2).first.to_i > 20000101
    end

    Sequel::IntegerMigrator
  else
    self
  end
end