Sha256: 04e75d592837b1a03f75386229ea9f9ac143b9045ec4e8d6ea6cd00b96e5cdf1

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

class Combustion::Database::Migrate
  def self.call
    new.call
  end

  def call
    if ActiveRecord::VERSION::STRING >= '3.1.0'
      migrator.migrate paths, nil
    else
      paths.each { |path| migrator.migrate path, nil }
    end
  end

  private

  def base_migration_paths
    if migrator.respond_to?(:migrations_paths)
      migrator.migrations_paths
    else
      Array('db/migrate/')
    end
  end

  def migrator
    @migrator ||= ActiveRecord::Migrator
  end

  def paths
    engine_path     = Rails.application.root.sub(::Combustion.path, '')
    migration_paths = Rails.application.paths['db/migrate'].to_a

    if migration_paths.include?(engine_path.join('db/migrate').to_s)
      paths = []
    else
      paths = base_migration_paths
    end

    (paths + migration_paths + [File.join(Rails.root, 'db/migrate')]).uniq
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
combustion-0.7.0 lib/combustion/database/migrate.rb
combustion-0.6.0 lib/combustion/database/migrate.rb
combustion-0.5.5 lib/combustion/database/migrate.rb