Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.backend.python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.backend.python
Commits
c99a354a
Commit
c99a354a
authored
6 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[database] Cleanup handling of schema version
This way beat/beat.core> doesn't depend on updating the is_v1 flag.
parent
af9db985
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!43
Cleanup handling of database schema version
Pipeline
#29340
passed
6 years ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/backend/python/database.py
+7
-11
7 additions, 11 deletions
beat/backend/python/database.py
with
7 additions
and
11 deletions
beat/backend/python/database.py
+
7
−
11
View file @
c99a354a
...
...
@@ -251,7 +251,6 @@ class Database(object):
self
.
errors
=
[]
self
.
data
=
None
self
.
is_v1
=
False
# if the user has not provided a cache, still use one for performance
dataformat_cache
=
dataformat_cache
if
dataformat_cache
is
not
None
else
{}
...
...
@@ -306,17 +305,14 @@ class Database(object):
self
.
code_path
=
self
.
storage
.
code
.
path
self
.
code
=
self
.
storage
.
code
.
load
()
schema_version
=
int
(
self
.
data
.
get
(
"
schema_version
"
,
1
))
if
schema_version
==
1
:
self
.
is_v1
=
True
if
self
.
schema_version
==
1
:
self
.
_load_v1
(
dataformat_cache
)
elif
schema_version
==
2
:
elif
self
.
schema_version
==
2
:
self
.
_load_v2
(
dataformat_cache
)
else
:
raise
RuntimeError
(
"
Invalid schema version {schema_version}
"
.
format
(
schema_version
=
schema_version
schema_version
=
self
.
schema_version
)
)
...
...
@@ -405,7 +401,7 @@ class Database(object):
def
sets
(
self
,
protocol
):
"""
The declaration of a specific set in the database protocol
"""
if
self
.
is_v
1
:
if
self
.
schema_version
==
1
:
data
=
self
.
protocol
(
protocol
)[
"
sets
"
]
else
:
protocol
=
self
.
protocol
(
protocol
)
...
...
@@ -426,7 +422,7 @@ class Database(object):
def
set_names
(
self
,
protocol
):
"""
The names of sets in a given protocol for this database
"""
if
self
.
is_v
1
:
if
self
.
schema_version
==
1
:
data
=
self
.
protocol
(
protocol
)[
"
sets
"
]
else
:
protocol
=
self
.
protocol
(
protocol
)
...
...
@@ -451,7 +447,7 @@ class Database(object):
"""
if
self
.
is_v
1
:
if
self
.
schema_version
==
1
:
view_definition
=
self
.
set
(
protocol_name
,
set_name
)
else
:
protocol
=
self
.
protocol
(
protocol_name
)
...
...
@@ -599,7 +595,7 @@ class Database(object):
for
k
in
self
.
dataformats
.
values
():
k
.
export
(
prefix
)
if
not
self
.
is_v
1
:
if
self
.
schema_version
!=
1
:
for
protocol
in
self
.
protocols
.
values
():
protocol_template
=
ProtocolTemplate
(
self
.
prefix
,
protocol
[
"
template
"
])
protocol_template
.
export
(
prefix
)
...
...
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