Skip to content

Commit

Permalink
fix: Add WorkflowExecution.started index (#3026)
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirFilonov authored Jan 14, 2025
1 parent 5846e46 commit 160d442
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Add workflowexecution.started index
Revision ID: 416155f25854
Revises: 1c117f1accff
Create Date: 2025-01-14 18:41:45.817371
"""

from alembic import op

# revision identifiers, used by Alembic.
revision = "416155f25854"
down_revision = "1c117f1accff"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###

with op.batch_alter_table("workflowexecution", schema=None) as batch_op:
batch_op.create_index(
batch_op.f("ix_workflowexecution_started"), ["started"], unique=False
)


def downgrade() -> None:
with op.batch_alter_table("workflowexecution", schema=None) as batch_op:
batch_op.drop_index(batch_op.f("ix_workflowexecution_started"))
2 changes: 1 addition & 1 deletion keep/api/models/db/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class WorkflowExecution(SQLModel, table=True):
id: str = Field(default=None, primary_key=True)
workflow_id: str = Field(foreign_key="workflow.id")
tenant_id: str = Field(foreign_key="tenant.id")
started: datetime = Field(default_factory=datetime.utcnow)
started: datetime = Field(default_factory=datetime.utcnow, index=True)
triggered_by: str = Field(sa_column=Column(TEXT))
status: str = Field(sa_column=Column(TEXT))
is_running: int = Field(default=1)
Expand Down

0 comments on commit 160d442

Please sign in to comment.