Skip to content

Automate browser based workflows with AI

create partial index alembic migrations (#5003)

Shuchang Zheng5cc73fcbceb7
diff --git a/alembic/versions/2026_03_06_1804-08f585f2e7a6_partial_index_for_artifacts_table.py b/alembic/versions/2026_03_06_1804-08f585f2e7a6_partial_index_for_artifacts_table.py
new file mode 100644
index 000000000..0a492e33e
--- /dev/null
+++ b/alembic/versions/2026_03_06_1804-08f585f2e7a6_partial_index_for_artifacts_table.py
@@ -0,0 +1,73 @@
+"""partial index for artifacts table
+
+Revision ID: 08f585f2e7a6
+Revises: a86c9fdba6b3
+Create Date: 2026-03-06 18:04:47.414053+00:00
+
+"""
+
+from typing import Sequence, Union
+
+import sqlalchemy as sa
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision: str = "08f585f2e7a6"
+down_revision: Union[str, None] = "a86c9fdba6b3"
+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(
+ "ix_artifacts_observer_cruise_id_partial",
+ "artifacts",
+ ["observer_cruise_id"],
+ unique=False,
+ postgresql_where=sa.text("observer_cruise_id IS NOT NULL"),
+ )
+ op.create_index(
+ "ix_artifacts_observer_thought_id_partial",
+ "artifacts",
+ ["observer_thought_id"],
+ unique=False,
+ postgresql_where=sa.text("observer_thought_id IS NOT NULL"),
+ )
+ op.create_index(
+ "ix_artifacts_run_id_partial",
+ "artifacts",
+ ["run_id"],
+ unique=False,
+ postgresql_where=sa.text("run_id IS NOT NULL"),
+ )
+ op.create_index(
+ "ix_artifacts_workflow_run_block_id_partial",
+ "artifacts",
+ ["workflow_run_block_id"],
+ unique=False,
+ postgresql_where=sa.text("workflow_run_block_id IS NOT NULL"),
+ )
+ # ### end Alembic commands ###
+
+
+def downgrade() -> None:
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_index(
+ "ix_artifacts_workflow_run_block_id_partial",
+ table_name="artifacts",
+ postgresql_where=sa.text("workflow_run_block_id IS NOT NULL"),
+ )
+ op.drop_index("ix_artifacts_run_id_partial", table_name="artifacts", postgresql_where=sa.text("run_id IS NOT NULL"))
+ op.drop_index(
+ "ix_artifacts_observer_thought_id_partial",
+ table_name="artifacts",
+ postgresql_where=sa.text("observer_thought_id IS NOT NULL"),
+ )
+ op.drop_index(
+ "ix_artifacts_observer_cruise_id_partial",
+ table_name="artifacts",
+ postgresql_where=sa.text("observer_cruise_id IS NOT NULL"),
+ )
+ # ### end Alembic commands ###
diff --git a/log/x11vnc.err b/log/x11vnc.err
new file mode 100644
index 000000000..e69de29bb
diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py
index 6548a4e16..58e7dfc6e 100644
--- a/skyvern/forge/sdk/db/models.py
+++ b/skyvern/forge/sdk/db/models.py
@@ -15,6 +15,7 @@ from sqlalchemy import (
UnicodeText,
UniqueConstraint,
desc,
+ text,
)
from sqlalchemy.ext.asyncio import AsyncAttrs
from sqlalchemy.orm import DeclarativeBase
@@ -205,6 +206,26 @@ class ArtifactModel(Base):
__table_args__ = (
Index("org_task_step_index", "organization_id", "task_id", "step_id"),
Index("artifacts_org_created_at_index", "organization_id", "created_at"),
+ Index(
+ "ix_artifacts_workflow_run_block_id_partial",
+ "workflow_run_block_id",
+ postgresql_where=text("workflow_run_block_id IS NOT NULL"),
+ ),
+ Index(
+ "ix_artifacts_observer_thought_id_partial",
+ "observer_thought_id",
+ postgresql_where=text("observer_thought_id IS NOT NULL"),
+ ),
+ Index(
+ "ix_artifacts_observer_cruise_id_partial",
+ "observer_cruise_id",
+ postgresql_where=text("observer_cruise_id IS NOT NULL"),
+ ),
+ Index(
+ "ix_artifacts_run_id_partial",
+ "run_id",
+ postgresql_where=text("run_id IS NOT NULL"),
+ ),
)
artifact_id = Column(String, primary_key=True, default=generate_artifact_id)