mirror of
https://github.com/langgenius/dify.git
synced 2026-03-01 12:55:13 +00:00
Compare commits
2 Commits
move-token
...
fix/conver
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80360da8b6 | ||
|
|
ee1aee01a3 |
@@ -0,0 +1,37 @@
|
|||||||
|
"""add partial indexes on conversations for app_id with created_at and updated_at
|
||||||
|
|
||||||
|
Revision ID: e288952f2994
|
||||||
|
Revises: fce013ca180e
|
||||||
|
Create Date: 2026-02-26 13:36:45.928922
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'e288952f2994'
|
||||||
|
down_revision = 'fce013ca180e'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
with op.batch_alter_table('conversations', schema=None) as batch_op:
|
||||||
|
batch_op.create_index(
|
||||||
|
'conversation_app_created_at_idx',
|
||||||
|
['app_id', sa.literal_column('created_at DESC')],
|
||||||
|
unique=False,
|
||||||
|
postgresql_where=sa.text('is_deleted IS false'),
|
||||||
|
)
|
||||||
|
batch_op.create_index(
|
||||||
|
'conversation_app_updated_at_idx',
|
||||||
|
['app_id', sa.literal_column('updated_at DESC')],
|
||||||
|
unique=False,
|
||||||
|
postgresql_where=sa.text('is_deleted IS false'),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
with op.batch_alter_table('conversations', schema=None) as batch_op:
|
||||||
|
batch_op.drop_index('conversation_app_updated_at_idx', postgresql_where=sa.text('is_deleted IS false'))
|
||||||
|
batch_op.drop_index('conversation_app_created_at_idx', postgresql_where=sa.text('is_deleted IS false'))
|
||||||
@@ -711,6 +711,18 @@ class Conversation(Base):
|
|||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
sa.PrimaryKeyConstraint("id", name="conversation_pkey"),
|
sa.PrimaryKeyConstraint("id", name="conversation_pkey"),
|
||||||
sa.Index("conversation_app_from_user_idx", "app_id", "from_source", "from_end_user_id"),
|
sa.Index("conversation_app_from_user_idx", "app_id", "from_source", "from_end_user_id"),
|
||||||
|
sa.Index(
|
||||||
|
"conversation_app_created_at_idx",
|
||||||
|
"app_id",
|
||||||
|
sa.text("created_at DESC"),
|
||||||
|
postgresql_where=sa.text("is_deleted IS false"),
|
||||||
|
),
|
||||||
|
sa.Index(
|
||||||
|
"conversation_app_updated_at_idx",
|
||||||
|
"app_id",
|
||||||
|
sa.text("updated_at DESC"),
|
||||||
|
postgresql_where=sa.text("is_deleted IS false"),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
id: Mapped[str] = mapped_column(StringUUID, default=lambda: str(uuid4()))
|
id: Mapped[str] = mapped_column(StringUUID, default=lambda: str(uuid4()))
|
||||||
|
|||||||
Reference in New Issue
Block a user