Sha256: 01e3c8a11688ad00ea8ce13496cca294fbfc2a8903a0793644f8e83a2e0df23f

Contents?: true

Size: 1.08 KB

Versions: 21

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

# TODO: - remove this once/if Heroku fixes this.
# Refer: https://devcenter.heroku.com/changelog-items/2446
# https://stackoverflow.com/a/73273766

module NeetoCommonsBackend
  module Initializers
    module EnableExtensionHerokuMonkeypatch
      def self.apply_patch!
        if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
          patched_method = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.instance_method(:enable_extension)
          # Only patch this method if it's method signature matches what we're expecting
          ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend InstanceMethods if patched_method&.arity == 1
        end
      end

      module InstanceMethods
        def enable_extension(name)
          name_override = name

          if schema_exists?("heroku_ext")
            Rails.logger.debug "enable_extension -- Adding SCHEMA heroku_ext"
            name_override = "#{name}\" SCHEMA heroku_ext -- Ignore trailing double quote"
          end

          super name_override
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.109 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.108 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.107 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.106 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.105 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.104 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.103 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.102 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.101 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.100 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.99 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.98 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.97 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.96 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.95 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.94 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.93 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.92 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.91 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb
neeto-commons-backend-1.0.90 lib/neeto_commons_backend/initializers/_enable_extension_hack.rb