Skip to content

Commit ae5db79

Browse files
authored
Migrations related to 9999881 (#2560)
1 parent ffd80fe commit ae5db79

5 files changed

+37
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (C) 2010-2015 Cuckoo Foundation.
2+
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
3+
# See the file 'docs/LICENSE' for copying permission.
4+
5+
"""Add ON DELETE CASCADE to tasks_tags foreign keys
6+
7+
Revision ID: 4e000e02a409
8+
Revises: c2bd0eb5e69d
9+
Create Date: 2025-04-11 09:58:42.957359
10+
11+
"""
12+
13+
# revision identifiers, used by Alembic.
14+
revision = '4e000e02a409'
15+
down_revision = 'c2bd0eb5e69d'
16+
17+
from alembic import op
18+
19+
20+
def upgrade():
21+
op.drop_constraint('tasks_tags_task_id_fkey', 'tasks_tags', type_='foreignkey')
22+
op.create_foreign_key('tasks_tags_task_id_fkey', 'tasks_tags', 'tasks', ['task_id'], ['id'], ondelete='CASCADE')
23+
24+
op.drop_constraint('tasks_tags_tag_id_fkey', 'tasks_tags', type_='foreignkey')
25+
op.create_foreign_key('tasks_tags_tag_id_fkey', 'tasks_tags', 'tags', ['tag_id'], ['id'], ondelete='CASCADE')
26+
27+
28+
def downgrade():
29+
op.drop_constraint('tasks_tags_task_id_fkey', 'tasks_tags', type_='foreignkey')
30+
op.create_foreign_key('tasks_tags_task_id_fkey', 'tasks_tags', 'tasks', ['task_id'], ['id'])
31+
32+
op.drop_constraint('tasks_tags_tag_id_fkey', 'tasks_tags', type_='foreignkey')
33+
op.create_foreign_key('tasks_tags_tag_id_fkey', 'tasks_tags', 'tags', ['tag_id'], ['id'])

utils/db_migration/versions/from_0_6_to_1_1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
print("Unable to import alembic (install with `poetry run pip install alembic`)")
3535
sys.exit()
3636

37-
sys.path.append(os.path.join("..", ".."))
37+
sys.path.append(os.path.join("..", "..", ".."))
3838

3939
import lib.cuckoo.core.database as db
4040
from lib.cuckoo.common.config import Config

utils/db_migration/versions/from_1_1_to_1_2-added_states.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
sys.exit()
3535

3636
curdir = os.path.abspath(os.path.dirname(__file__))
37-
sys.path.append(os.path.join(curdir, "..", ".."))
37+
sys.path.append(os.path.join(curdir, "..", "..", ".."))
3838

3939
import lib.cuckoo.core.database as db
4040

utils/db_migration/versions/from_1_1_to_1_2-extend_file_type.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from alembic import op
2323

2424
curdir = os.path.abspath(os.path.dirname(__file__))
25-
sys.path.append(os.path.join(curdir, "..", ".."))
25+
sys.path.append(os.path.join(curdir, "..", "..", ".."))
2626

2727
import lib.cuckoo.core.database as db
2828

utils/db_migration/versions/from_1_2_to_1_2-accuvant-add_statistics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
sys.exit()
3535

3636
curdir = os.path.abspath(os.path.dirname(__file__))
37-
sys.path.append(os.path.join(curdir, "..", ".."))
37+
sys.path.append(os.path.join(curdir, "..", "..", ".."))
3838

3939
import lib.cuckoo.core.database as db
4040

0 commit comments

Comments
 (0)