Commit 6e2b295b authored by Andreas Brandl's avatar Andreas Brandl

Add initializer to warn on unsupported PG version

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/224683
parent 1c7f6906
......@@ -2,3 +2,27 @@
raise "PostgreSQL is the only supported database from GitLab 12.1" unless
Gitlab::Database.postgresql?
begin
puts ERB.new(Rainbow.new.wrap(<<~EOS).red).result unless Gitlab::Database.postgresql_minimum_supported_version? # rubocop:disable Rails/Output
██  ██  █████  ██████  ███  ██ ██ ███  ██  ██████ 
██  ██ ██   ██ ██   ██ ████  ██ ██ ████  ██ ██      
██  █  ██ ███████ ██████  ██ ██  ██ ██ ██ ██  ██ ██  ███ 
██ ███ ██ ██   ██ ██   ██ ██  ██ ██ ██ ██  ██ ██ ██  ██ 
 ███ ███  ██  ██ ██  ██ ██   ████ ██ ██   ████  ██████  
******************************************************************************
You are using PostgreSQL <%= Gitlab::Database.version %>, but PostgreSQL >= <%= Gitlab::Database::MINIMUM_POSTGRES_VERSION %>
is required for this version of GitLab.
<% if Rails.env.development? || Rails.env.test? %>
If using gitlab-development-kit, please find the relevant steps here:
https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/master/doc/howto/postgresql.md#upgrade-postgresql
<% end %>
Please upgrade your environment to a supported PostgreSQL version, see
https://docs.gitlab.com/ee/install/requirements.html#database for details.
******************************************************************************
EOS
rescue ActiveRecord::ActiveRecordError, PG::Error
# ignore - happens when Rake tasks yet have to create a database, e.g. for testing
end
......@@ -4,6 +4,8 @@ module Gitlab
module Database
include Gitlab::Metrics::Methods
MINIMUM_POSTGRES_VERSION = 11
# https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
MAX_INT_VALUE = 2147483647
......@@ -102,7 +104,7 @@ module Gitlab
end
def self.postgresql_minimum_supported_version?
version.to_f >= 11
version.to_f >= MINIMUM_POSTGRES_VERSION
end
def self.upsert_supported?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment