-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix unable to delete tagged node issue (#586)
- Loading branch information
Showing
6 changed files
with
212 additions
and
2 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
papermerge/core/alembic/versions/88b6b2d497ea_add_ondelete_cascase_to_node_tags.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,51 @@ | ||
"""add ondelete cascade to nodes tags | ||
Revision ID: 88b6b2d497ea | ||
Revises: f0e0da122a9a | ||
Create Date: 2025-02-01 08:20:24.361716 | ||
""" | ||
|
||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "88b6b2d497ea" | ||
down_revision: Union[str, None] = "f0e0da122a9a" | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_foreign_key( | ||
"nodes_user_id_fkey", | ||
"nodes", | ||
"users", | ||
["user_id"], | ||
["id"], | ||
ondelete="CASCADE", | ||
use_alter=True, | ||
) | ||
op.drop_constraint("nodes_tags_node_id_fkey", "nodes_tags", type_="foreignkey") | ||
op.create_foreign_key( | ||
None, "nodes_tags", "nodes", ["node_id"], ["id"], ondelete="CASCADE" | ||
) | ||
op.create_foreign_key( | ||
"tag_user_id_fk", "tags", "users", ["user_id"], ["id"], use_alter=True | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint("tag_user_id_fk", "tags", type_="foreignkey") | ||
op.drop_constraint(None, "nodes_tags", type_="foreignkey") | ||
op.create_foreign_key( | ||
"nodes_tags_node_id_fkey", "nodes_tags", "nodes", ["node_id"], ["id"] | ||
) | ||
op.drop_constraint("nodes_user_id_fkey", "nodes", type_="foreignkey") | ||
# ### end Alembic commands ### |
32 changes: 32 additions & 0 deletions
32
papermerge/core/alembic/versions/bafd773c8533_add_on_casecase_delete_for_tags_.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,32 @@ | ||
"""add on casecase=delete for tags association table | ||
Revision ID: bafd773c8533 | ||
Revises: 88b6b2d497ea | ||
Create Date: 2025-02-01 08:59:18.660765 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = 'bafd773c8533' | ||
down_revision: Union[str, None] = '88b6b2d497ea' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint('nodes_tags_tag_id_fkey', 'nodes_tags', type_='foreignkey') | ||
op.create_foreign_key(None, 'nodes_tags', 'tags', ['tag_id'], ['id'], ondelete='CASCADE') | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint(None, 'nodes_tags', type_='foreignkey') | ||
op.create_foreign_key('nodes_tags_tag_id_fkey', 'nodes_tags', 'tags', ['tag_id'], ['id']) | ||
# ### end Alembic commands ### |
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
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