Merge remote-tracking branch 'origin/rs-database-info'
This commit is contained in:
commit
dfe12649f6
|
@ -17,6 +17,7 @@ v 8.5.0 (unreleased)
|
||||||
- Display 404 error on group not found
|
- Display 404 error on group not found
|
||||||
- Track project import failure
|
- Track project import failure
|
||||||
- Support Two-factor Authentication for LDAP users
|
- Support Two-factor Authentication for LDAP users
|
||||||
|
- Display database type and version in Administration dashboard
|
||||||
- Fix visibility level text in admin area (Zeger-Jan van de Weg)
|
- Fix visibility level text in admin area (Zeger-Jan van de Weg)
|
||||||
- Warn admin during OAuth of granting admin rights (Zeger-Jan van de Weg)
|
- Warn admin during OAuth of granting admin rights (Zeger-Jan van de Weg)
|
||||||
- Update the ExternalIssue regex pattern (Blake Hitchcock)
|
- Update the ExternalIssue regex pattern (Blake Hitchcock)
|
||||||
|
|
|
@ -92,6 +92,11 @@
|
||||||
Rails
|
Rails
|
||||||
%span.pull-right
|
%span.pull-right
|
||||||
#{Rails::VERSION::STRING}
|
#{Rails::VERSION::STRING}
|
||||||
|
|
||||||
|
%p
|
||||||
|
= Gitlab::Database.adapter_name
|
||||||
|
%span.pull-right
|
||||||
|
= Gitlab::Database.version
|
||||||
%hr
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-sm-4
|
.col-sm-4
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
module Gitlab
|
module Gitlab
|
||||||
module Database
|
module Database
|
||||||
|
def self.adapter_name
|
||||||
|
connection.adapter_name
|
||||||
|
end
|
||||||
|
|
||||||
def self.mysql?
|
def self.mysql?
|
||||||
ActiveRecord::Base.connection.adapter_name.downcase == 'mysql2'
|
adapter_name.downcase == 'mysql2'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.postgresql?
|
def self.postgresql?
|
||||||
ActiveRecord::Base.connection.adapter_name.downcase == 'postgresql'
|
adapter_name.downcase == 'postgresql'
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.version
|
||||||
|
database_version.match(/\A(?:PostgreSQL |)([^\s]+).*\z/)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def true_value
|
def true_value
|
||||||
case ActiveRecord::Base.connection.adapter_name.downcase
|
if self.class.postgresql?
|
||||||
when 'postgresql'
|
|
||||||
"'t'"
|
"'t'"
|
||||||
else
|
else
|
||||||
1
|
1
|
||||||
|
@ -18,12 +25,31 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def false_value
|
def false_value
|
||||||
case ActiveRecord::Base.connection.adapter_name.downcase
|
if self.class.postgresql?
|
||||||
when 'postgresql'
|
|
||||||
"'f'"
|
"'f'"
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def self.connection
|
||||||
|
ActiveRecord::Base.connection
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.database_version
|
||||||
|
row = connection.execute("SELECT VERSION()").first
|
||||||
|
|
||||||
|
if postgresql?
|
||||||
|
row['version']
|
||||||
|
else
|
||||||
|
row.first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def connection
|
||||||
|
self.class.connection
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,4 +14,24 @@ describe Gitlab::Database, lib: true do
|
||||||
|
|
||||||
it { is_expected.to satisfy { |val| val == true || val == false } }
|
it { is_expected.to satisfy { |val| val == true || val == false } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.version' do
|
||||||
|
context "on mysql" do
|
||||||
|
it "extracts the version number" do
|
||||||
|
allow(described_class).to receive(:database_version).
|
||||||
|
and_return("5.7.12-standard")
|
||||||
|
|
||||||
|
expect(described_class.version).to eq '5.7.12-standard'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "on postgresql" do
|
||||||
|
it "extracts the version number" do
|
||||||
|
allow(described_class).to receive(:database_version).
|
||||||
|
and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0")
|
||||||
|
|
||||||
|
expect(described_class.version).to eq '9.4.4'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue