Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
f82ec39c
Commit
f82ec39c
authored
8 years ago
by
Megan Henning
Browse files
Options
Downloads
Patches
Plain Diff
Add upgrade script
parent
c4916e41
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/database.py
+34
-1
34 additions, 1 deletion
bin/database.py
with
34 additions
and
1 deletion
bin/database.py
+
34
−
1
View file @
f82ec39c
...
...
@@ -8,8 +8,10 @@ import logging
import
sys
from
api
import
config
from
api.dao
import
containerutil
from
api.jobs.jobs
import
Job
CURRENT_DATABASE_VERSION
=
1
1
# An int that is bumped when a new schema change is made
CURRENT_DATABASE_VERSION
=
1
2
# An int that is bumped when a new schema change is made
def
get_db_version
():
...
...
@@ -333,6 +335,35 @@ def upgrade_to_11():
{
'
$set
'
:
{
'
inputs
'
:
inputs_arr
}}
)
def
upgrade_to_12
():
"""
scitran/core PR #372
Store job inputs on job-based analyses
"""
sessions
=
config
.
db
.
sessions
.
find
({
'
analyses.job
'
:
{
'
$exists
'
:
True
}})
for
session
in
sessions
:
for
analysis
in
session
.
get
(
'
analyses
'
):
if
analysis
.
get
(
'
job
'
):
job
=
Job
.
get
(
analysis
[
'
job
'
])
files
=
analysis
.
get
(
'
files
'
,
[])
files
[:]
=
[
x
for
x
in
files
if
x
.
get
(
'
output
'
)]
# remove any existing inputs and insert fresh
for
i
in
getattr
(
job
,
'
inputs
'
,
{}):
fileref
=
job
.
inputs
[
i
]
contref
=
containerutil
.
create_containerreference_from_filereference
(
job
.
inputs
[
i
])
file_
=
contref
.
find_file
(
fileref
.
name
)
if
file_
:
file_
[
'
input
'
]
=
True
files
.
append
(
file_
)
q
=
{
'
analyses._id
'
:
analysis
[
'
_id
'
]}
u
=
{
'
$set
'
:
{
'
analyses.$.job
'
:
job
.
_id
,
'
analyses.$.files
'
:
files
}}
config
.
db
.
sessions
.
update_one
(
q
,
u
)
def
upgrade_schema
():
"""
Upgrades db to the current schema version
...
...
@@ -364,6 +395,8 @@ def upgrade_schema():
upgrade_to_10
()
if
db_version
<
11
:
upgrade_to_11
()
if
db_version
<
12
:
upgrade_to_12
()
except
Exception
as
e
:
logging
.
exception
(
'
Incremental upgrade of db failed
'
)
...
...
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