Module: RailsSQLPrettifier::ProtectedEnv

Included in:
Niceql
Defined in:
lib/rails_sql_prettifier/protected_env.rb

Instance Method Summary collapse

Instance Method Details

#protected_env?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
# File 'lib/rails_sql_prettifier/protected_env.rb', line 5

def protected_env?
  migration_context = ActiveRecord::Base.connection.try(:migration_context) ||
    ActiveRecord::Base.connection.try(:pool)&.migration_context # rails 7.2+

  migration_context&.protected_environment? ||
    defined?(Rails) && !(Rails.env.test? || Rails.env.development?)
end