Sha256: f7f48e5c83854b4a3be51ea497868a853874b2a8c7ad1fcf5e218ed17c31c279

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module Multiverse
  module DatabaseTasks
    def each_current_configuration(environment)
      if Multiverse.db
        environments = ["#{Multiverse.db}_#{environment}"]
        environments << "#{Multiverse.db}_test" if environment == "development"
        self.migrations_paths = Multiverse.migrate_path
        self.db_dir = Multiverse.db_dir
      else
        environments = [environment]
        environments << "test" if environment == "development"
      end

      configurations = ActiveRecord::Base.configurations.values_at(*environments)
      configurations.compact.each do |configuration|
        yield configuration unless configuration['database'].blank?
      end
    end
  end

  module Migration
    def connection
      @connection || Multiverse.record_class.connection
    end

    # TODO don't checkout main connection at all
    def exec_migration(_, direction)
      Multiverse.record_class.connection_pool.with_connection do |conn|
        super(conn, direction)
      end
    end
  end

  module SchemaMigration
    def connection
      Multiverse.record_class.connection
    end
  end

  module SchemaDumper
    def dump(connection = ActiveRecord::Base.connection, stream = STDOUT, config = ActiveRecord::Base)
      new(Multiverse.record_class.connection, generate_options(Multiverse.record_class)).dump(stream)
      stream
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multiverse-0.0.1 lib/multiverse/patches.rb