Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csentry
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Harrisson
csentry
Commits
58bca5af
Commit
58bca5af
authored
6 years ago
by
Benjamin Bertrand
Browse files
Options
Downloads
Patches
Plain Diff
Fix database migration when the database is empty
parent
9d2bdae1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
migrations/versions/ac04850e5f68_add_is_ioc_field.py
+12
-11
12 additions, 11 deletions
migrations/versions/ac04850e5f68_add_is_ioc_field.py
with
12 additions
and
11 deletions
migrations/versions/ac04850e5f68_add_is_ioc_field.py
+
12
−
11
View file @
58bca5af
...
...
@@ -32,17 +32,18 @@ def upgrade():
conn
=
op
.
get_bind
()
res
=
conn
.
execute
(
"
SELECT id FROM tag WHERE name =
'
IOC
'
;
"
)
row
=
res
.
fetchone
()
ioc_tag_id
=
row
[
0
]
res
.
close
()
res
=
conn
.
execute
(
f
"""
SELECT interface.host_id FROM interface
INNER JOIN interfacetags ON interface.id = interfacetags.interface_id
WHERE interfacetags.tag_id =
{
ioc_tag_id
}
;
"""
)
results
=
res
.
fetchall
()
for
result
in
results
:
op
.
execute
(
host
.
update
().
where
(
host
.
c
.
id
==
result
[
0
]).
values
(
is_ioc
=
True
))
if
row
is
not
None
:
ioc_tag_id
=
row
[
0
]
res
.
close
()
res
=
conn
.
execute
(
f
"""
SELECT interface.host_id FROM interface
INNER JOIN interfacetags ON interface.id = interfacetags.interface_id
WHERE interfacetags.tag_id =
{
ioc_tag_id
}
;
"""
)
results
=
res
.
fetchall
()
for
result
in
results
:
op
.
execute
(
host
.
update
().
where
(
host
.
c
.
id
==
result
[
0
]).
values
(
is_ioc
=
True
))
op
.
drop_table
(
"
interfacetags
"
)
op
.
drop_table
(
"
tag
"
)
...
...
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