-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Remove the foreign key constraint of vfolders.{user,group} (#…
…2404) refs #2376 Remove the foreign/check constraints preventing decoupling of user/vfolder deletions. **Checklist:** (if applicable) - [x] Milestone metadata specifying the target backport version - [x] Mention to the original issue
- Loading branch information
1 parent
45ba2ed
commit 136f505
Showing
5 changed files
with
65 additions
and
22 deletions.
There are no files selected for viewing
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 @@ | ||
Remove database-level foreign key constraints in `vfolders.{user,group}` columns to decouple the timing of vfolder deletion and user/group deletion. |
38 changes: 38 additions & 0 deletions
38
...r/models/alembic/versions/59a622c31820_remove_foreign_key_in_vfolders_user_and_project.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,38 @@ | ||
"""Remove foreign key constraint from vfolders to users and projects | ||
Revision ID: 59a622c31820 | ||
Revises: fdb2dcdb8811 | ||
Create Date: 2024-07-08 22:54:20.762521 | ||
""" | ||
|
||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "59a622c31820" | ||
down_revision = "fdb2dcdb8811" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.drop_constraint("fk_vfolders_user_users", "vfolders", type_="foreignkey") | ||
op.drop_constraint("fk_vfolders_group_groups", "vfolders", type_="foreignkey") | ||
op.drop_constraint("ck_vfolders_ownership_type_match_with_user_or_group", "vfolders") | ||
op.drop_constraint("ck_vfolders_either_one_of_user_or_group", "vfolders") | ||
|
||
|
||
def downgrade(): | ||
op.create_foreign_key("fk_vfolders_group_groups", "vfolders", "groups", ["group"], ["id"]) | ||
op.create_foreign_key("fk_vfolders_user_users", "vfolders", "users", ["user"], ["uuid"]) | ||
op.create_check_constraint( | ||
"ck_vfolders_ownership_type_match_with_user_or_group", | ||
"vfolders", | ||
"(ownership_type = 'user' AND \"user\" IS NOT NULL) OR " | ||
"(ownership_type = 'group' AND \"group\" IS NOT NULL)", | ||
) | ||
op.create_check_constraint( | ||
"ck_vfolders_either_one_of_user_or_group", | ||
"vfolders", | ||
'("user" IS NULL AND "group" IS NOT NULL) OR ("user" IS NOT NULL AND "group" IS NULL)', | ||
) |
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
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
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