add idx_job_id for workflow run (#3655)

This commit is contained in:
LawyZheng
2025-10-09 16:30:40 +08:00
committed by GitHub
parent 26f1f37738
commit 9cf6034952
2 changed files with 36 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
"""add job id idx
Revision ID: 7cd6f55be8d2
Revises: 8d015c5358f8
Create Date: 2025-10-09 08:27:14.047236+00:00
"""
from typing import Sequence, Union
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "7cd6f55be8d2"
down_revision: Union[str, None] = "8d015c5358f8"
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! ###
with op.get_context().autocommit_block():
op.execute("SET statement_timeout = '3h';")
op.execute("""
CREATE INDEX CONCURRENTLY IF NOT EXISTS ix_workflow_runs_job_id
ON workflow_runs (job_id);
""")
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.get_context().autocommit_block():
op.execute("DROP INDEX IF EXISTS ix_workflow_runs_job_id;")
# ### end Alembic commands ###

View File

@@ -288,7 +288,7 @@ class WorkflowRunModel(Base):
extra_http_headers = Column(JSON, nullable=True)
browser_address = Column(String, nullable=True)
script_run = Column(JSON, nullable=True)
job_id = Column(String, nullable=True)
job_id = Column(String, nullable=True, index=True)
depends_on_workflow_run_id = Column(String, nullable=True)
sequential_key = Column(String, nullable=True)
run_with = Column(String, nullable=True) # 'agent' or 'code'