-
Notifications
You must be signed in to change notification settings - Fork 427
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.document_id
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
h/migrations/versions/7418b43b64c3_anno_slim_document_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,36 @@ | ||
"""Add CASCADE on deletion for annotation_slim.document_id.""" | ||
from alembic import op | ||
|
||
revision = "7418b43b64c3" | ||
down_revision = "3081971a50fc" | ||
|
||
|
||
def upgrade(): | ||
op.drop_constraint( | ||
"fk__annotation_slim__document_id__document", | ||
"annotation_slim", | ||
type_="foreignkey", | ||
) | ||
op.create_foreign_key( | ||
op.f("fk__annotation_slim__document_id__document"), | ||
"annotation_slim", | ||
"document", | ||
["document_id"], | ||
["id"], | ||
ondelete="CASCADE", | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_constraint( | ||
op.f("fk__annotation_slim__document_id__document"), | ||
"annotation_slim", | ||
type_="foreignkey", | ||
) | ||
op.create_foreign_key( | ||
"fk__annotation_slim__document_id__document", | ||
"annotation_slim", | ||
"document", | ||
["document_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