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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Deprecation warning for < postgres13 in admin/info
Oliver Güntherac16c3721461
diff --git a/app/views/admin/info.html.erb b/app/views/admin/info.html.erbindex 0cd4f9c9249..d605d29dab4 100644--- a/app/views/admin/info.html.erb+++ b/app/views/admin/info.html.erb@@ -54,6 +54,28 @@ See docs/COPYRIGHT.rdoc for more details.<span><%= @db_version %></span></div></div>+ <% if OpenProject::Database.version_deprecated? %>+ <div class="attributes-key-value--key"></div>+ <div class="attributes-key-value--value-container">+ <div class="attributes-key-value--value -text">+ <strong>+ <%= op_icon 'icon3 icon-warning' %>+ Deprecation warning:+ </strong>+ <p>+ The next major release of OpenProject will update the requirements+ on the required PostgreSQL database version.+ <br/>+ Starting with OpenProject 12.0, anticipated end of 2021, PostgreSQL 13 will be required+ to use OpenProject.+ <br/>+ We have prepared <%= static_link_to :postgres_13_upgrade,+ label: 'upgrade guides for all installation methods' %>.+ You can perform the upgrade ahead of the release at any time by following the guides.+ </p>+ </div>+ </div>+ <% end %><% if display_security_badge_graphic? %><div class="attributes-key-value--key"></div><div class="attributes-key-value--value-container">@@ -95,38 +117,38 @@ See docs/COPYRIGHT.rdoc for more details.</div></div>-<% @storage_information.each_with_index do |(_,entries), i| %>-<%= content_tag :h3, t(:label_storage_group, identifier: i + 1) %>-<div class="attributes-group">- <div class="attributes-key-value">- <div class="attributes-key-value--key"><%= t(:label_storage_for) %></div>- <div class="attributes-key-value--value-container">- <div class="attributes-key-value--value -text">+<% @storage_information.each_with_index do |(_, entries), i| %>+ <%= content_tag :h3, t(:label_storage_group, identifier: i + 1) %>+ <div class="attributes-group">+ <div class="attributes-key-value">+ <div class="attributes-key-value--key"><%= t(:label_storage_for) %></div>+ <div class="attributes-key-value--value-container">+ <div class="attributes-key-value--value -text"><span><% entries[:labels].each do |l| %><%= l %><br/><% end %></span>+ </div></div>- </div>- <div class="attributes-key-value--key"><%= t(:label_storage_free_space) %></div>- <div class="attributes-key-value--value-container">- <div class="attributes-key-value--value -text">- <span><%= number_to_human_size(entries[:data][:free], precision: 2) %></span>+ <div class="attributes-key-value--key"><%= t(:label_storage_free_space) %></div>+ <div class="attributes-key-value--value-container">+ <div class="attributes-key-value--value -text">+ <span><%= number_to_human_size(entries[:data][:free], precision: 2) %></span>+ </div></div>- </div>- <div class="attributes-key-value--key"><%= t(:label_storage_used_space) %></div>- <div class="attributes-key-value--value-container">- <div class="attributes-key-value--value -text">+ <div class="attributes-key-value--key"><%= t(:label_storage_used_space) %></div>+ <div class="attributes-key-value--value-container">+ <div class="attributes-key-value--value -text"><span><%= number_to_human_size(entries[:data][:used], precision: 2) %>(<%= entries[:data][:percent_used].round(2) %> %)</span>+ </div></div></div></div>-</div><% end %><%= call_hook(:view_admin_info_bottom) %>diff --git a/lib/open_project/database.rb b/lib/open_project/database.rbindex c816d98de69..e57717a4835 100644--- a/lib/open_project/database.rb+++ b/lib/open_project/database.rb@@ -43,6 +43,8 @@ module OpenProjectclass UnsupportedDatabaseError < StandardError; end+ class DeprecatedVersionWarning < StandardError; end+# This method returns a hash which maps the identifier of the supported# adapter to a regex matching the adapter_name.def self.supported_adapters@@ -80,6 +82,12 @@ module OpenProjectfalseend+ ##+ # Determine whether the current version is deprecated+ def self.version_deprecated?+ !version_matches?(130000)+ end+### Check the database for# * being postgresql@@ -104,13 +112,19 @@ module OpenProject"but current version is #{current}"raise InsufficientVersionError.new message+ elsif version_deprecated?+ message = "The next major release of OpenProject (v12) will require PostgreSQL 13 or later.\n" \+ "You can anticipate this upgrade by updating your database installation by following the guide at " \+ "https://docs.openproject.org/installation-and-operations/misc/migration-to-postgresql13/"++ raise DeprecatedVersionWarning.new messageendend### Return +true+ if the required version is matched by the current connection.- def self.version_matches?- numeric_version >= required_version[:numeric]+ def self.version_matches?(required_numeric_version = nil)+ numeric_version >= (required_numeric_version || required_version[:numeric])end# Get the raw name of the currently used database adapter.diff --git a/lib/open_project/static/links.rb b/lib/open_project/static/links.rbindex 5f4f4ffa53f..80613e28fc3 100644--- a/lib/open_project/static/links.rb+++ b/lib/open_project/static/links.rb@@ -110,6 +110,9 @@ module OpenProjecthref: 'https://www.openproject.org/operations/migration-guides/migrating-packaged-openproject-database-postgresql/',label: :'homescreen.links.postgres_migration'},+ postgres_13_upgrade: {+ href: 'https://docs.openproject.org/installation-and-operations/misc/migration-to-postgresql13/'+ },configuration_guide: {href: 'https://www.openproject.org/operations/configuration/',label: 'links.configuration_guide'diff --git a/lib/tasks/database.rake b/lib/tasks/database.rakeindex 5e243a828e3..9940bf3fc3e 100644--- a/lib/tasks/database.rake+++ b/lib/tasks/database.rake@@ -62,6 +62,7 @@ namespace 'openproject' doOpenProject::Database::check!rescue OpenProject::Database::UnsupportedDatabaseError => ewarn <<~MESSAGE+---------------------------------------------------DATABASE UNSUPPORTED ERROR@@ -74,6 +75,7 @@ namespace 'openproject' doKernel.exit(1)rescue OpenProject::Database::InsufficientVersionError => ewarn <<~MESSAGE+---------------------------------------------------DATABASE INCOMPATIBILITY ERROR@@ -84,6 +86,15 @@ namespace 'openproject' do---------------------------------------------------MESSAGEKernel.exit(1)+ rescue OpenProject::Database::DeprecatedVersionWarning => e+ warn <<~MESSAGE++ ---------------------------------------------------+ DATABASE DEPRECATION WARNING++ #{e.message}+ ---------------------------------------------------+ MESSAGErescue ActiveRecord::ActiveRecordError => ewarn "Failed to perform postgres version check: #{e} - #{e.message}. #{override_msg}"raise e