Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions lib/modulorails/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,16 @@ def initialize_from_configuration

def initialize_from_database
# Get the database connection to identify the database used by the application
# or return nil if the database does not exist
db_connection = begin
ActiveRecord::Base.connection
rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished => e
warn("[Modulorails] Error: #{e.message}")
nil
end
db_connection = ActiveRecord::Base.connection || return

# The name of the ActiveRecord adapter; it gives the name of the database system too
@adapter = db_connection&.adapter_name&.downcase
@adapter = db_connection.adapter_name.downcase

# The version of the database engine; this request works only on MySQL and PostgreSQL
# It should not be a problem since those are the sole database engines used at Modulotech
@db_version = db_connection&.select_value('SELECT version()')
@db_version = db_connection.select_value('SELECT version()')
rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished => e
warn("[Modulorails] Error: #{e.message}")
end

def initialize_from_gem_specs
Expand Down