Module: Gitlab::Database

Defined in:
lib/gitlab/database.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.adapter_nameObject


3
4
5
# File 'lib/gitlab/database.rb', line 3

def self.adapter_name
  connection.adapter_name
end

.mysql?Boolean

Returns:

  • (Boolean)

7
8
9
# File 'lib/gitlab/database.rb', line 7

def self.mysql?
  adapter_name.downcase == 'mysql2'
end

.postgresql?Boolean

Returns:

  • (Boolean)

11
12
13
# File 'lib/gitlab/database.rb', line 11

def self.postgresql?
  adapter_name.downcase == 'postgresql'
end

.versionObject


15
16
17
# File 'lib/gitlab/database.rb', line 15

def self.version
  database_version.match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1]
end

Instance Method Details

#false_valueObject


27
28
29
30
31
32
33
# File 'lib/gitlab/database.rb', line 27

def false_value
  if Gitlab::Database.postgresql?
    "'f'"
  else
    0
  end
end

#true_valueObject


19
20
21
22
23
24
25
# File 'lib/gitlab/database.rb', line 19

def true_value
  if Gitlab::Database.postgresql?
    "'t'"
  else
    1
  end
end