Sha256: d8cae35c467cc547dff167bf92498819d50883280caec3b9fa58775a9c855a3f
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
module Marty::Diagnostic::Database def self.db_name ActiveRecord::Base.connection_config[:database] end def self.db_server_name ActiveRecord::Base.connection_config[:host] || 'undefined' end def self.db_adapter_name ActiveRecord::Base.connection.adapter_name end def self.db_time ActiveRecord::Base.connection.execute('SELECT NOW();')[0]['now'] end def self.db_version ActiveRecord::Base.connection.execute('SELECT VERSION();')[0]['version'] end def self.db_schema current = ActiveRecord::Migrator.current_version raise "Migration is needed.\nCurrent Version: #{current}" if Rails.version >= '5.2.0' && ActiveRecord::Base.connection.migration_context.needs_migration? current.to_s end def self.get_postgres_connections conn = ActiveRecord::Base.connection.execute('SELECT datname,'\ 'application_name,'\ 'state,'\ 'pid,'\ 'client_addr '\ 'FROM pg_stat_activity') conn.each_with_object({}) do |conn, h| h[conn['datname']] ||= [] h[conn['datname']] << conn.except('datname') end end def self.current_connections get_postgres_connections[db_name] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
marty-6.1.0 | lib/marty/diagnostic/database.rb |
marty-5.2.0 | other/marty/diagnostic/database.rb |