File tree 1 file changed +27
-0
lines changed
utils/db_migration/versions
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
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);" )
You can’t perform that action at this time.
0 commit comments