From 11108e8d2e326f72d8ccbc720a86b148ce07fc40 Mon Sep 17 00:00:00 2001 From: David Whittaker Date: Mon, 4 Nov 2024 16:19:02 -0800 Subject: [PATCH] Cleaning up alembic migration files --- .../versions/2024-11-04_928b725d64f6.py | 50 +++++++++++++++++++ src/dispatch/signal/models.py | 13 ----- 2 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py diff --git a/src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py b/src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py new file mode 100644 index 000000000000..429f311fbcab --- /dev/null +++ b/src/dispatch/database/revisions/tenant/versions/2024-11-04_928b725d64f6.py @@ -0,0 +1,50 @@ +"""Fixes automatic generation issues + +Revision ID: 928b725d64f6 +Revises: 3edb0476365a +Create Date: 2024-11-04 15:55:57.864691 + +""" + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.engine.reflection import Inspector + +# revision identifiers, used by Alembic. +revision = "928b725d64f6" +down_revision = "3edb0476365a" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + conn = op.get_bind() + inspector = Inspector.from_engine(conn) + + # Check if the table exists + if "service_incident" in inspector.get_table_names(): + op.drop_table("service_incident") + + op.alter_column( + "entity", "source", existing_type=sa.BOOLEAN(), type_=sa.String(), existing_nullable=True + ) + + op.drop_index("ix_entity_search_vector", table_name="entity", postgresql_using="gin") + op.create_index( + "entity_search_vector_idx", + "entity", + ["search_vector"], + unique=False, + postgresql_using="gin", + ) + op.alter_column("entity_type", "jpath", existing_type=sa.VARCHAR(), nullable=True) + op.drop_column("plugin_instance", "configuration") + op.drop_constraint("project_stable_priority_id_fkey", "project", type_="foreignkey") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### diff --git a/src/dispatch/signal/models.py b/src/dispatch/signal/models.py index a0fc51e5ce8d..a41177165595 100644 --- a/src/dispatch/signal/models.py +++ b/src/dispatch/signal/models.py @@ -48,19 +48,6 @@ class RuleMode(DispatchEnum): inactive = "Inactive" -assoc_signal_instance_tags = Table( - "assoc_signal_instance_tags", - Base.metadata, - Column( - "signal_instance_id", - UUID(as_uuid=True), - ForeignKey("signal_instance.id", ondelete="CASCADE"), - ), - Column("tag_id", Integer, ForeignKey("tag.id", ondelete="CASCADE")), - PrimaryKeyConstraint("signal_instance_id", "tag_id"), -) - - assoc_signal_tags = Table( "assoc_signal_tags", Base.metadata,