From a627cc709e95fb0aa409bdff906930c6204b54d4 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 23 Jan 2026 19:59:12 +0200 Subject: [PATCH] add index on public_share_enabled --- .../versions/79_add_public_share_to_chat_threads.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/surfsense_backend/alembic/versions/79_add_public_share_to_chat_threads.py b/surfsense_backend/alembic/versions/79_add_public_share_to_chat_threads.py index 25195d6ee..ce02064c0 100644 --- a/surfsense_backend/alembic/versions/79_add_public_share_to_chat_threads.py +++ b/surfsense_backend/alembic/versions/79_add_public_share_to_chat_threads.py @@ -49,9 +49,21 @@ def upgrade() -> None: """ ) + # Add partial index on public_share_enabled for fast public chat queries + op.execute( + """ + CREATE INDEX ix_new_chat_threads_public_share_enabled + ON new_chat_threads(public_share_enabled) + WHERE public_share_enabled = TRUE + """ + ) + def downgrade() -> None: """Remove public sharing columns from new_chat_threads.""" + op.drop_index( + "ix_new_chat_threads_public_share_enabled", table_name="new_chat_threads" + ) op.drop_index( "ix_new_chat_threads_public_share_token", table_name="new_chat_threads" )