Skip to content

Automate browser based workflows with AI

add artifacts_org_created_at_index for artifacts table (#2755)

Shuchang Zheng27add941fffc
diff --git a/alembic/versions/2025_06_19_2259-afeed80576cb_add_index_for_artifacts_table_.py b/alembic/versions/2025_06_19_2259-afeed80576cb_add_index_for_artifacts_table_.py
new file mode 100644
index 000000000..6f54a07df
--- /dev/null
+++ b/alembic/versions/2025_06_19_2259-afeed80576cb_add_index_for_artifacts_table_.py
@@ -0,0 +1,29 @@
+"""add index for artifacts table (organization_id, created_at)
+
+Revision ID: afeed80576cb
+Revises: 2d2f165170f1
+Create Date: 2025-06-19 22:59:31.436342+00:00
+
+"""
+
+from typing import Sequence, Union
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision: str = "afeed80576cb"
+down_revision: Union[str, None] = "2d2f165170f1"
+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("artifacts_org_created_at_index", "artifacts", ["organization_id", "created_at"], unique=False)
+ # ### end Alembic commands ###
+
+
+def downgrade() -> None:
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_index("artifacts_org_created_at_index", table_name="artifacts")
+ # ### end Alembic commands ###
diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py
index 3907d2eaa..825318c84 100644
--- a/skyvern/forge/sdk/db/models.py
+++ b/skyvern/forge/sdk/db/models.py
@@ -177,7 +177,10 @@ class OrganizationAuthTokenModel(Base):
class ArtifactModel(Base):
__tablename__ = "artifacts"
- __table_args__ = (Index("org_task_step_index", "organization_id", "task_id", "step_id"),)
+ __table_args__ = (
+ Index("org_task_step_index", "organization_id", "task_id", "step_id"),
+ Index("artifacts_org_created_at_index", "organization_id", "created_at"),
+ )
artifact_id = Column(String, primary_key=True, default=generate_artifact_id)
organization_id = Column(String, ForeignKey("organizations.organization_id"))