-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a CASCADE on delete for annotation_slim.user_id
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
h/migrations/versions/28a982795769_anno_slim_user_cascade.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Add CASCADE on deletion for annotation_slim.user.""" | ||
from alembic import op | ||
|
||
revision = "28a982795769" | ||
down_revision = "15b5dc900ebb" | ||
|
||
|
||
def upgrade(): | ||
op.drop_constraint( | ||
"fk__annotation_slim__user_id__user", "annotation_slim", type_="foreignkey" | ||
) | ||
op.create_foreign_key( | ||
op.f("fk__annotation_slim__user_id__user"), | ||
"annotation_slim", | ||
"user", | ||
["user_id"], | ||
["id"], | ||
ondelete="CASCADE", | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_constraint( | ||
op.f("fk__annotation_slim__user_id__user"), | ||
"annotation_slim", | ||
type_="foreignkey", | ||
) | ||
op.create_foreign_key( | ||
"fk__annotation_slim__user_id__user", | ||
"annotation_slim", | ||
"user", | ||
["user_id"], | ||
["id"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters