Skip to content

Commit a09208b

Browse files
committed
Add pending_message index on time field
1 parent bb3d24d commit a09208b

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Add pending_message index on time field
2+
3+
Revision ID: 35a67ccc4451
4+
Revises: 8ece21fbeb47
5+
Create Date: 2025-09-04 08:29:17.540060
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = '35a67ccc4451'
14+
down_revision = '8ece21fbeb47'
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade() -> None:
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.create_index(op.f('ix_pending_messages_time'), 'pending_messages', ['time'], unique=False)
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade() -> None:
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.drop_index(op.f('ix_pending_messages_time'), table_name='pending_messages')
28+
# ### end Alembic commands ###

src/aleph/db/models/pending_messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PendingMessageDb(Base):
5858
item_type: ItemType = Column(ChoiceType(ItemType), nullable=False)
5959
item_content = Column(String, nullable=True)
6060
content: Optional[Dict[str, Any]] = Column(JSONB, nullable=True)
61-
time: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False)
61+
time: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False, index=True)
6262
channel: Optional[Channel] = Column(String, nullable=True)
6363

6464
reception_time: dt.datetime = Column(TIMESTAMP(timezone=True), nullable=False)

0 commit comments

Comments
 (0)