Skip to content

Commit

Permalink
Merge pull request #4309 from alphagov/ris-rm-ix-notifications-servic…
Browse files Browse the repository at this point in the history
…e-id-composite

`Notification`: remove `ix_notifications_service_id_composite` index
  • Loading branch information
risicle authored Dec 16, 2024
2 parents aac3813 + 1a68921 commit bf78beb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 0 additions & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,6 @@ class Notification(db.Model):
UniqueConstraint("job_id", "job_row_number", name="uq_notifications_job_row_number"),
Index("ix_notifications_notification_type_composite", "notification_type", "status", "created_at"),
Index("ix_notifications_service_created_at", "service_id", "created_at"),
Index("ix_notifications_service_id_composite", "service_id", "notification_type", "status", "created_at"),
Index("ix_notifications_service_id_ntype_created_at", "service_id", "notification_type", "created_at"),
# unsubscribe_link value should be null for non-email notifications
CheckConstraint(
Expand Down
2 changes: 1 addition & 1 deletion migrations/.current-alembic-head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0482_ft_ntfcn_stat_tpt_date_idx
0483_rm_ntfcn_service_composite
32 changes: 32 additions & 0 deletions migrations/versions/0483_rm_ntfcn_service_composite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Create Date: 2024-12-13 10:26:32.802054
"""

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

revision = "0483_rm_ntfcn_service_composite"
down_revision = "0482_ft_ntfcn_stat_tpt_date_idx"


def upgrade():
with op.get_context().autocommit_block():
op.drop_index(
"ix_notifications_service_id_composite",
table_name="notifications",
if_exists=True,
postgresql_concurrently=True,
)


def downgrade():
with op.get_context().autocommit_block():
op.create_index(
"ix_notifications_service_id_composite",
"notifications",
["service_id", "notification_type", "notification_status", "created_at"],
if_not_exists=True,
unique=False,
postgresql_concurrently=True,
)

0 comments on commit bf78beb

Please sign in to comment.