Skip to content

Commit 0a18cf5

Browse files
committed
Add migration for foreign key changes made to tasks_tags in 9999881
1 parent 7075bdf commit 0a18cf5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.execute("ALTER TABLE tasks_tags DROP CONSTRAINT tasks_tags_task_id_fkey, ADD CONSTRAINT tasks_tags_task_id_fkey FOREIGN KEY (task_id) REFERENCES tasks (id) ON DELETE CASCADE;")
22+
op.execute("ALTER TABLE tasks_tags DROP CONSTRAINT tasks_tags_tag_id_fkey, ADD CONSTRAINT tasks_tags_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tags (id) ON DELETE CASCADE;")
23+
24+
25+
def downgrade():
26+
op.execute("ALTER TABLE tasks_tags DROP CONSTRAINT tasks_tags_task_id_fkey, ADD CONSTRAINT tasks_tags_task_id_fkey FOREIGN KEY (task_id) REFERENCES tasks (id);")
27+
op.execute("ALTER TABLE tasks_tags DROP CONSTRAINT tasks_tags_tag_id_fkey, ADD CONSTRAINT tasks_tags_tag_id_fkey FOREIGN KEY (tag_id) REFERENCES tags (id);")

0 commit comments

Comments
 (0)