diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /lib/gitlab/database.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'lib/gitlab/database.rb')
-rw-r--r-- | lib/gitlab/database.rb | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb index accc6330253..45d271a2fd4 100644 --- a/lib/gitlab/database.rb +++ b/lib/gitlab/database.rb @@ -92,10 +92,6 @@ module Gitlab @version ||= database_version.match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1] end - def self.postgresql_9_or_less? - version.to_f < 10 - end - def self.postgresql_minimum_supported_version? version.to_f >= MINIMUM_POSTGRES_VERSION end @@ -127,28 +123,6 @@ module Gitlab # ignore - happens when Rake tasks yet have to create a database, e.g. for testing end - # map some of the function names that changed between PostgreSQL 9 and 10 - # https://wiki.postgresql.org/wiki/New_in_postgres_10 - def self.pg_wal_lsn_diff - Gitlab::Database.postgresql_9_or_less? ? 'pg_xlog_location_diff' : 'pg_wal_lsn_diff' - end - - def self.pg_current_wal_insert_lsn - Gitlab::Database.postgresql_9_or_less? ? 'pg_current_xlog_insert_location' : 'pg_current_wal_insert_lsn' - end - - def self.pg_last_wal_receive_lsn - Gitlab::Database.postgresql_9_or_less? ? 'pg_last_xlog_receive_location' : 'pg_last_wal_receive_lsn' - end - - def self.pg_last_wal_replay_lsn - Gitlab::Database.postgresql_9_or_less? ? 'pg_last_xlog_replay_location' : 'pg_last_wal_replay_lsn' - end - - def self.pg_last_xact_replay_timestamp - 'pg_last_xact_replay_timestamp' - end - def self.nulls_last_order(field, direction = 'ASC') Arel.sql("#{field} #{direction} NULLS LAST") end @@ -276,6 +250,20 @@ module Gitlab false end + def self.system_id + row = connection.execute('SELECT system_identifier FROM pg_control_system()').first + + row['system_identifier'] + end + + def self.get_write_location(ar_connection) + row = ar_connection + .select_all("SELECT pg_current_wal_insert_lsn()::text AS location") + .first + + row['location'] if row + end + private_class_method :database_version def self.add_post_migrate_path_to_rails(force: false) |