diff --git a/alembic/versions/2024_07_17_2227-94bc3829eed6_add_step_id_index_to_artifacts_table.py b/alembic/versions/2024_07_17_2227-94bc3829eed6_add_step_id_index_to_artifacts_table.py new file mode 100644 index 00000000..3ba59354 --- /dev/null +++ b/alembic/versions/2024_07_17_2227-94bc3829eed6_add_step_id_index_to_artifacts_table.py @@ -0,0 +1,29 @@ +"""add step_id index to artifacts table + +Revision ID: 94bc3829eed6 +Revises: 370cb81c73e7 +Create Date: 2024-07-17 22:27:30.734057+00:00 + +""" + +from typing import Sequence, Union + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "94bc3829eed6" +down_revision: Union[str, None] = "370cb81c73e7" +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.create_index(op.f("ix_artifacts_step_id"), "artifacts", ["step_id"], unique=False) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index(op.f("ix_artifacts_step_id"), table_name="artifacts") + # ### end Alembic commands ### diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py index e864f0c7..ec5f5cf9 100644 --- a/skyvern/forge/sdk/db/models.py +++ b/skyvern/forge/sdk/db/models.py @@ -148,7 +148,7 @@ class ArtifactModel(Base): artifact_id = Column(String, primary_key=True, index=True, default=generate_artifact_id) organization_id = Column(String, ForeignKey("organizations.organization_id")) task_id = Column(String, ForeignKey("tasks.task_id")) - step_id = Column(String, ForeignKey("steps.step_id")) + step_id = Column(String, ForeignKey("steps.step_id"), index=True) artifact_type = Column(String) uri = Column(String) created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)