Module: Gitlab::DatabaseWarnings

Defined in:
lib/gitlab/database_warnings.rb

Class Method Summary collapse

Class Method Details

.check_postgres_version_and_print_warningObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gitlab/database_warnings.rb', line 5

def self.check_postgres_version_and_print_warning
  return if Gitlab::Runtime.rails_runner?

  Gitlab::Database.database_base_models.each do |name, model|
    database = Gitlab::Database::Reflection.new(model)

    next if database.postgresql_minimum_supported_version?

    Kernel.warn ERB.new(Rainbow.new.wrap(<<~WARNING).red).result

                ██     ██  █████  ██████  ███    ██ ██ ███    ██  ██████ 
                ██     ██ ██   ██ ██   ██ ████   ██ ██ ████   ██ ██      
                ██  █  ██ ███████ ██████  ██ ██  ██ ██ ██ ██  ██ ██   ███ 
                ██ ███ ██ ██   ██ ██   ██ ██  ██ ██ ██ ██  ██ ██ ██    ██ 
                 ███ ███  ██   ██ ██   ██ ██   ████ ██ ██   ████  ██████  

      ******************************************************************************
        You are using PostgreSQL #{database.version} for the #{name} database, but this version of GitLab requires PostgreSQL >= <%= Gitlab::Database::MINIMUM_POSTGRES_VERSION %>.
        <% 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/main/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.
      ******************************************************************************
    WARNING
  rescue ActiveRecord::ActiveRecordError, PG::Error
    # ignore - happens when Rake tasks yet have to create a database, e.g. for testing
  end
end

.check_single_connection_and_print_warningObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/gitlab/database_warnings.rb', line 36

def self.check_single_connection_and_print_warning
  return if Gitlab::Runtime.rails_runner?
  return unless Gitlab::Database.database_mode == Gitlab::Database::MODE_SINGLE_DATABASE

  Kernel.warn ERB.new(Rainbow.new.wrap(<<~WARNING).red).result

              ██     ██  █████  ██████  ███    ██ ██ ███    ██  ██████ 
              ██     ██ ██   ██ ██   ██ ████   ██ ██ ████   ██ ██      
              ██  █  ██ ███████ ██████  ██ ██  ██ ██ ██ ██  ██ ██   ███ 
              ██ ███ ██ ██   ██ ██   ██ ██  ██ ██ ██ ██  ██ ██ ██    ██ 
               ███ ███  ██   ██ ██   ██ ██   ████ ██ ██   ████  ██████  

    ******************************************************************************
      Your database has a single connection, and single connections were
      deprecated in GitLab 15.9 https://docs.gitlab.com/ee/update/deprecations.html#single-database-connection-is-deprecated.

      Please add a :ci section to your database, following these instructions:
      https://docs.gitlab.com/ee/install/installation.html#configure-gitlab-db-settings.
    ******************************************************************************
  WARNING
end