Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Improve message when nulldb is being used (#9156)

Oliver Günther2b0bce6b5cc3
diff --git a/lib/open_project/database.rb b/lib/open_project/database.rb
index 80ba82363cb..c816d98de69 100644
--- a/lib/open_project/database.rb
+++ b/lib/open_project/database.rb
@@ -89,9 +89,7 @@ module OpenProject
# Raises an +InsufficientVersionError+ when the version is incompatible
def self.check!
if !postgresql?
- message = "Database server is not PostgreSql. " \
- "As OpenProject uses non standard ANSI-SQL for performance optimizations, using a different DBMS will " \
- "break and is thus prevented."
+ message = "OpenProject requires a PostgreSQL database, but database adapter is set to #{adapter_name}."
if adapter_name.match?(/mysql/i)
message << " As MySql used to be supported, there is a migration script to ease the transition " \
@@ -119,6 +117,9 @@ module OpenProject
# This string is set by the used adapter gem.
def self.adapter_name(connection = self.connection)
connection.adapter_name
+ rescue StandardError => e
+ Rails.logger.error "Failed to retrieve database adapter name #{e} #{e.message}"
+ "Unknown due to error #{e}"
end
# Get the AR base connection object handle
diff --git a/lib/open_project/null_db_fallback.rb b/lib/open_project/null_db_fallback.rb
index c1ae1a91937..09c33053b6c 100644
--- a/lib/open_project/null_db_fallback.rb
+++ b/lib/open_project/null_db_fallback.rb
@@ -33,7 +33,8 @@ module OpenProject
class << self
def fallback
ActiveRecord::Base.connection
- rescue ActiveRecord::NoDatabaseError
+ rescue ActiveRecord::NoDatabaseError => e
+ Rails.logger.error "Database connection could not be established: #{e}. Falling back to NullDB."
applied!
ActiveRecord::Base.establish_connection adapter: :nulldb
end