Sha256: 7d32a8a115b4e38c4c5db1f31b0cbafcbbc5de60b3f4b6658f45a5b4a2dbea3a

Contents?: true

Size: 1.25 KB

Versions: 12

Compression:

Stored size: 1.25 KB

Contents

require "active_record/migration/compatibility"

module PgHaMigrations
  module ActiveRecordHacks
    module CleanupUnnecessaryOutput
      # This is fixed in Rails 6+, but previously there were several
      # places where #adapter_name was called directly which implicitly
      # delegated to the connection through #method_missing. That
      # delegation though results in wrapping the call in #say_with_time
      # which unnecessarily outputs a bunch of calls to #adapter_name.
      # The easiest way to clean this up retroactively is to just patch
      # in a direct dispatch to the connection's method.
      #
      # See: https://github.com/rails/rails/commit/eb7c71bcd3d0c7e079dffdb11e43fb466eec06aa
      def adapter_name
        connection.adapter_name
      end
    end
  end
end

patchable_module = [
 defined?(ActiveRecord::Migration::Compatibility::V5_2) ? ActiveRecord::Migration::Compatibility::V5_2 : nil,
 defined?(ActiveRecord::Migration::Compatibility::V5_1) ? ActiveRecord::Migration::Compatibility::V5_1 : nil,
 defined?(ActiveRecord::Migration::Compatibility::V5_0) ? ActiveRecord::Migration::Compatibility::V5_0 : nil,
].detect { |m| m }
if patchable_module
  patchable_module.prepend(PgHaMigrations::ActiveRecordHacks::CleanupUnnecessaryOutput)
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pg_ha_migrations-1.8.0 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.7.0 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.6.0 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.5.0 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.4.0 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.3.0 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.2.5 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.2.4 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.2.3 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.2.2 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.2.1 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb
pg_ha_migrations-1.2.0 lib/pg_ha_migrations/hacks/cleanup_unnecessary_output.rb