Skip to content

Commit

Permalink
Updated triggers on child entities that were preventing deletion (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
katybaulch authored Nov 29, 2023
1 parent 6f9ce33 commit c389011
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 3 deletions.
6 changes: 3 additions & 3 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
signature="update_family_last_modified",
on_entity="public.family_document",
definition="""
BEFORE INSERT OR UPDATE OR DELETE ON public.family_document
AFTER INSERT OR UPDATE OR DELETE ON public.family_document
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_family_last_modified()
""",
Expand All @@ -139,7 +139,7 @@
signature="update_family_last_modified",
on_entity="public.family_event",
definition="""
BEFORE INSERT OR UPDATE OR DELETE ON public.family_event
AFTER INSERT OR UPDATE OR DELETE ON public.family_event
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_family_last_modified()
""",
Expand All @@ -162,7 +162,7 @@
signature="update_collection_last_modified ",
on_entity="public.collection_family",
definition="""
BEFORE INSERT OR UPDATE OR DELETE ON public.collection_family
AFTER INSERT OR UPDATE OR DELETE ON public.collection_family
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_collection_last_modified()
""",
Expand Down
102 changes: 102 additions & 0 deletions alembic/versions/0025_fixed_event_trigger_that_was_preventing_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""
Fixed event trigger that was preventing event deletion
Revision ID: 0025
Revises: 0024
Create Date: 2023-11-29 13:53:59.518084
"""
from alembic_utils.pg_trigger import PGTrigger

from alembic import op

# revision identifiers, used by Alembic.
revision = "0025"
down_revision = "0024"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
public_family_document_update_family_last_modified = PGTrigger(
schema="public",
signature="update_family_last_modified",
on_entity="public.family_document",
is_constraint=False,
definition="""
AFTER INSERT OR UPDATE OR DELETE ON public.family_document
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_family_last_modified()
""",
)
op.replace_entity(public_family_document_update_family_last_modified) # type: ignore

public_family_event_update_family_last_modified = PGTrigger(
schema="public",
signature="update_family_last_modified",
on_entity="public.family_event",
is_constraint=False,
definition="""
AFTER INSERT OR UPDATE OR DELETE ON public.family_event
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_family_last_modified()
""",
)
op.replace_entity(public_family_event_update_family_last_modified) # type: ignore

public_collection_family_update_collection_last_modified = PGTrigger(
schema="public",
signature="update_collection_last_modified",
on_entity="public.collection_family",
is_constraint=False,
definition="""
AFTER INSERT OR UPDATE OR DELETE ON public.collection_family
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_collection_last_modified()
""",
)
op.replace_entity(public_collection_family_update_collection_last_modified) # type: ignore

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
public_collection_family_update_collection_last_modified = PGTrigger(
schema="public",
signature="update_collection_last_modified",
on_entity="public.collection_family",
is_constraint=False,
definition="""
AFTER INSERT OR UPDATE OR DELETE ON public.collection_family
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_collection_last_modified()
""",
)
op.replace_entity(public_collection_family_update_collection_last_modified) # type: ignore
public_family_event_update_family_last_modified = PGTrigger(
schema="public",
signature="update_family_last_modified",
on_entity="public.family_event",
is_constraint=False,
definition="""
AFTER INSERT OR UPDATE OR DELETE ON public.family_event
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_family_last_modified()
""",
)
op.replace_entity(public_family_event_update_family_last_modified) # type: ignore
public_family_document_update_family_last_modified = PGTrigger(
schema="public",
signature="update_family_last_modified",
on_entity="public.family_document",
is_constraint=False,
definition="""
AFTER INSERT OR UPDATE OR DELETE ON public.family_document
FOR EACH ROW
EXECUTE PROCEDURE public.update_2_family_last_modified()
""",
)
op.replace_entity(public_family_document_update_family_last_modified) # type: ignore
# ### end Alembic commands ###

0 comments on commit c389011

Please sign in to comment.