Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
dfe12649
Commit
dfe12649
authored
Feb 04, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/rs-database-info'
parents
d9624bb8
4105f292
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
6 deletions
+58
-6
CHANGELOG
CHANGELOG
+1
-0
app/views/admin/dashboard/index.html.haml
app/views/admin/dashboard/index.html.haml
+5
-0
lib/gitlab/database.rb
lib/gitlab/database.rb
+32
-6
spec/lib/gitlab/database_spec.rb
spec/lib/gitlab/database_spec.rb
+20
-0
No files found.
CHANGELOG
View file @
dfe12649
...
...
@@ -17,6 +17,7 @@ v 8.5.0 (unreleased)
- Display 404 error on group not found
- Track project import failure
- 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)
- Warn admin during OAuth of granting admin rights (Zeger-Jan van de Weg)
- Update the ExternalIssue regex pattern (Blake Hitchcock)
...
...
app/views/admin/dashboard/index.html.haml
View file @
dfe12649
...
...
@@ -92,6 +92,11 @@
Rails
%span
.pull-right
#{
Rails
::
VERSION
::
STRING
}
%p
=
Gitlab
::
Database
.
adapter_name
%span
.pull-right
=
Gitlab
::
Database
.
version
%hr
.row
.col-sm-4
...
...
lib/gitlab/database.rb
View file @
dfe12649
module
Gitlab
module
Database
def
self
.
adapter_name
connection
.
adapter_name
end
def
self
.
mysql?
ActiveRecord
::
Base
.
connection
.
adapter_name
.
downcase
==
'mysql2'
adapter_name
.
downcase
==
'mysql2'
end
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
def
true_value
case
ActiveRecord
::
Base
.
connection
.
adapter_name
.
downcase
when
'postgresql'
if
self
.
class
.
postgresql?
"'t'"
else
1
...
...
@@ -18,12 +25,31 @@ module Gitlab
end
def
false_value
case
ActiveRecord
::
Base
.
connection
.
adapter_name
.
downcase
when
'postgresql'
if
self
.
class
.
postgresql?
"'f'"
else
0
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
spec/lib/gitlab/database_spec.rb
View file @
dfe12649
...
...
@@ -14,4 +14,24 @@ describe Gitlab::Database, lib: true do
it
{
is_expected
.
to
satisfy
{
|
val
|
val
==
true
||
val
==
false
}
}
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment