From c1179124fa3e189846cc3b3ae044ca7a29efe0a0 Mon Sep 17 00:00:00 2001 From: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:10:57 -0800 Subject: [PATCH] Removes signal instance fingerprint column (#4047) * Removes unused fingerprint column from signal instance model * revision * more instances --- src/dispatch/case/models.py | 7 ++--- .../versions/2023-11-29_580a18ec4c39.py | 30 +++++++++++++++++++ src/dispatch/signal/models.py | 2 -- tests/factories.py | 1 - 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/dispatch/database/revisions/tenant/versions/2023-11-29_580a18ec4c39.py diff --git a/src/dispatch/case/models.py b/src/dispatch/case/models.py index 321812d94f83..458082b37cf2 100644 --- a/src/dispatch/case/models.py +++ b/src/dispatch/case/models.py @@ -182,12 +182,11 @@ class SignalRead(DispatchBase): class SignalInstanceRead(DispatchBase): - signal: SignalRead + created_at: datetime entities: Optional[List[EntityRead]] = [] - tags: Optional[List[TagRead]] = [] raw: Any - fingerprint: Optional[str] - created_at: datetime + signal: SignalRead + tags: Optional[List[TagRead]] = [] class ProjectRead(DispatchBase): diff --git a/src/dispatch/database/revisions/tenant/versions/2023-11-29_580a18ec4c39.py b/src/dispatch/database/revisions/tenant/versions/2023-11-29_580a18ec4c39.py new file mode 100644 index 000000000000..77270583353a --- /dev/null +++ b/src/dispatch/database/revisions/tenant/versions/2023-11-29_580a18ec4c39.py @@ -0,0 +1,30 @@ +"""Removes unused fingerprint column from signal instance model + +Revision ID: 580a18ec4c39 +Revises: bdaeabba3e53 +Create Date: 2023-11-29 15:40:12.524085 + +""" +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = "580a18ec4c39" +down_revision = "bdaeabba3e53" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("signal_instance", "fingerprint") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column( + "signal_instance", + sa.Column("fingerprint", sa.VARCHAR(), autoincrement=False, nullable=True), + ) + # ### end Alembic commands ### diff --git a/src/dispatch/signal/models.py b/src/dispatch/signal/models.py index 87371134cee4..e558810a346f 100644 --- a/src/dispatch/signal/models.py +++ b/src/dispatch/signal/models.py @@ -229,7 +229,6 @@ class SignalInstance(Base, TimeStampMixin, ProjectMixin): case_type = relationship("CaseType", backref="signal_instances") case_priority_id = Column(Integer, ForeignKey(CasePriority.id)) case_priority = relationship("CasePriority", backref="signal_instances") - fingerprint = Column(String) filter_action = Column(String) canary = Column(Boolean, default=False) raw = Column(JSONB) @@ -381,7 +380,6 @@ class SignalInstanceCreate(SignalInstanceBase): class SignalInstanceRead(SignalInstanceBase): id: uuid.UUID - fingerprint: Optional[str] signal: SignalRead diff --git a/tests/factories.py b/tests/factories.py index bb39718abbc6..7b8291e5699a 100644 --- a/tests/factories.py +++ b/tests/factories.py @@ -831,7 +831,6 @@ class SignalInstanceFactory(BaseFactory): id = LazyFunction(uuid.uuid4) project = SubFactory(ProjectFactory) case = SubFactory(CaseFactory) - fingerprint = fake.md5() signal = SubFactory(SignalFactory) raw = { "action": [{"type": "AWS_API_CALL", "value": {"Api": "assumerole", "ServiceName": "sts"}}],