add db index idx_workflow_scripts_wpid_cache_key_value (#3331)

This commit is contained in:
Shuchang Zheng
2025-08-31 14:10:05 +08:00
committed by GitHub
parent 83b3cfb6af
commit 494b009ef9
2 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
"""update workflow_scripts wpid index
Revision ID: ee2f523ea454
Revises: f54bab75b1c4
Create Date: 2025-08-31 06:06:13.611883+00:00
"""
from typing import Sequence, Union
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "ee2f523ea454"
down_revision: Union[str, None] = "f54bab75b1c4"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("idx_workflow_scripts_workflow_permanent_id"), table_name="workflow_scripts")
op.create_index(
"idx_workflow_scripts_wpid_cache_key_value",
"workflow_scripts",
["workflow_permanent_id", "cache_key_value"],
unique=False,
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index("idx_workflow_scripts_wpid_cache_key_value", table_name="workflow_scripts")
op.create_index(
op.f("idx_workflow_scripts_workflow_permanent_id"), "workflow_scripts", ["workflow_permanent_id"], unique=False
)
# ### end Alembic commands ###

View File

@@ -863,7 +863,7 @@ class WorkflowScriptModel(Base):
__tablename__ = "workflow_scripts"
__table_args__ = (
Index("idx_workflow_scripts_org_created", "organization_id", "created_at"),
Index("idx_workflow_scripts_workflow_permanent_id", "workflow_permanent_id"),
Index("idx_workflow_scripts_wpid_cache_key_value", "workflow_permanent_id", "cache_key_value"),
)
workflow_script_id = Column(String, primary_key=True, default=generate_workflow_script_id)