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

Move mysql error early into application boot

Oliver Günther0182215f8c4a
diff --git a/config/application.rb b/config/application.rb
index 9e96300de05..b5de2b751fd 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -73,6 +73,29 @@ end
require File.dirname(__FILE__) + '/../lib/open_project/configuration'
+env = ENV['RAILS_ENV'] || 'production'
+db_config = ActiveRecord::Base.configurations[env] || {}
+db_adapter = db_config['adapter']
+if db_adapter&.start_with? 'mysql'
+ warn <<~ERROR
+ ======= INCOMPATIBLE DATABASE DETECTED =======
+ Your database is set up for use with a MySQL or MySQL-compatible variant.
+ This installation of OpenProject 10.0. no longer supports these variants.
+
+ The following guides provide extensive documentation for migrating
+ your installation to a PostgreSQL database:
+
+ https://www.openproject.org/migration-guides/
+
+ This process is mostly automated so you can continue using your
+ OpenProject installation within a few minutes!
+
+ ==============================================
+ ERROR
+
+ Kernel.exit 1
+end
+
module OpenProject
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
diff --git a/config/initializers/01-mysql-error.rb b/config/initializers/01-mysql-error.rb
deleted file mode 100644
index 5989461439b..00000000000
--- a/config/initializers/01-mysql-error.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-db_adapter = ActiveRecord::Base.configurations[Rails.env]['adapter']
-if db_adapter.start_with? 'mysql'
- warn <<~ERROR
- ======= INCOMPATIBLE DATABASE DETECTED =======
- Your database is set up for use with a MySQL or MySQL-compatible variant.
- This installation of OpenProject 10.0. no longer supports these variants.
-
- The following guides provide extensive documentation for migrating
- your installation to a PostgreSQL database:
-
- https://www.openproject.org/migration-guides/
-
- This process is mostly automated so you can continue using your
- OpenProject installation within a few minutes!
-
- ==============================================
- ERROR
-
- Kernel.exit 1
-end