From 29b9cc814f5d39bb0d2bd03a1ebef942b070e2fd Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Mon, 23 Mar 2026 20:22:48 +0200 Subject: [PATCH] fix: make migration 104 idempotent with if_not_exists on index creation The notification composite indexes may already exist from the model's __table_args__, causing DuplicateTableError on fresh migrations. --- .../versions/104_add_notification_composite_indexes.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/surfsense_backend/alembic/versions/104_add_notification_composite_indexes.py b/surfsense_backend/alembic/versions/104_add_notification_composite_indexes.py index 69e97eb0d..c3afb58d0 100644 --- a/surfsense_backend/alembic/versions/104_add_notification_composite_indexes.py +++ b/surfsense_backend/alembic/versions/104_add_notification_composite_indexes.py @@ -30,21 +30,25 @@ def upgrade() -> None: "ix_notifications_user_read_type_created", "notifications", ["user_id", "read", "type", "created_at"], + if_not_exists=True, ) op.create_index( "ix_notifications_user_space_created", "notifications", ["user_id", "search_space_id", "created_at"], + if_not_exists=True, ) op.create_index( "ix_notifications_type", "notifications", ["type"], + if_not_exists=True, ) op.create_index( "ix_notifications_search_space_id", "notifications", ["search_space_id"], + if_not_exists=True, )