Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
eb362bb9
Commit
eb362bb9
authored
3 weeks ago
by
Erwan Rouchet
Committed by
Bastien Abadie
3 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
Add database version system check
parent
7010fb6d
No related branches found
No related tags found
1 merge request
!2541
Add database version system check
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/project/checks.py
+19
-1
19 additions, 1 deletion
arkindex/project/checks.py
arkindex/project/tests/test_checks.py
+23
-0
23 additions, 0 deletions
arkindex/project/tests/test_checks.py
with
42 additions
and
1 deletion
arkindex/project/checks.py
+
19
−
1
View file @
eb362bb9
...
...
@@ -9,7 +9,8 @@ import os
import
re
import
sys
from
django.core.checks
import
Critical
,
Error
,
Warning
,
register
from
django.core.checks
import
Critical
,
Error
,
Tags
,
Warning
,
register
from
django.db
import
connections
from
arkindex.process.models
import
ArkindexFeature
,
WorkerVersion
...
...
@@ -350,3 +351,20 @@ def update_system_workers_check(*args, **kwargs):
f
"
then update its `version` to
{
settings
.
VERSION
!r}
.
"
,
id
=
"
arkindex.E012
"
,
)]
@register
(
Tags
.
database
)
def
database_version_check
(
databases
=
None
,
**
kwargs
):
if
databases
is
None
:
return
[]
issues
=
[]
for
alias
in
databases
:
major
,
minor
=
connections
[
alias
].
get_database_version
()
if
major
<
15
:
issues
.
append
(
Critical
(
"
Arkindex requires PostgreSQL 15 or later.
"
,
hint
=
f
"
Database
{
alias
}
reports version
{
major
}
.
{
minor
}
"
,
id
=
"
arkindex.C002
"
,
))
return
issues
This diff is collapsed.
Click to expand it.
arkindex/project/tests/test_checks.py
+
23
−
0
View file @
eb362bb9
...
...
@@ -4,6 +4,7 @@ from unittest.mock import patch
from
django.conf
import
settings
from
django.core.checks
import
Critical
,
Error
,
Warning
from
django.db
import
connections
from
django.test
import
TestCase
,
override_settings
from
django.urls
import
path
...
...
@@ -479,3 +480,25 @@ class ChecksTestCase(TestCase):
"
then update its `version` to
'
0.0.0
'
.
"
,
id
=
"
arkindex.E012
"
,
)])
def
test_database_version_check_none
(
self
):
from
arkindex.project.checks
import
database_version_check
self
.
assertListEqual
(
database_version_check
(),
[])
def
test_database_version_check_default
(
self
):
from
arkindex.project.checks
import
database_version_check
self
.
assertListEqual
(
database_version_check
([
"
default
"
]),
[])
@patch.object
(
connections
[
"
default
"
],
"
get_database_version
"
,
lambda
:
(
14
,
1
))
def
test_database_version_check_critical
(
self
):
from
arkindex.project.checks
import
database_version_check
self
.
assertListEqual
(
database_version_check
([
"
default
"
]),
[
Critical
(
"
Arkindex requires PostgreSQL 15 or later.
"
,
hint
=
"
Database default reports version 14.1
"
,
id
=
"
arkindex.C002
"
,
)
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment