Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Add org index to the actions table (#1673)
Shuchang Zhengd1e0a172ecf0
diff --git a/alembic/versions/2025_01_29_0738-df80b5d155d0_add_action_org_created_at_index.py b/alembic/versions/2025_01_29_0738-df80b5d155d0_add_action_org_created_at_index.pynew file mode 100644index 000000000..b6fca5a62--- /dev/null+++ b/alembic/versions/2025_01_29_0738-df80b5d155d0_add_action_org_created_at_index.py@@ -0,0 +1,33 @@+"""add action_org_created_at_index++Revision ID: df80b5d155d0+Revises: 3aa0ef96942d+Create Date: 2025-01-29 07:38:58.641024+00:00++"""++from typing import Sequence, Union++import sqlalchemy as sa++from alembic import op++# revision identifiers, used by Alembic.+revision: str = "df80b5d155d0"+down_revision: Union[str, None] = "3aa0ef96942d"+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(+ "action_org_created_at_index", "actions", ["organization_id", sa.text("created_at DESC")], unique=False+ )+ # ### end Alembic commands ###+++def downgrade() -> None:+ # ### commands auto generated by Alembic - please adjust! ###+ op.drop_index("action_org_created_at_index", table_name="actions")+ # ### end Alembic commands ###diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.pyindex 3864d544d..6c60cf9d9 100644--- a/skyvern/forge/sdk/db/models.py+++ b/skyvern/forge/sdk/db/models.py@@ -13,6 +13,7 @@ from sqlalchemy import (String,UnicodeText,UniqueConstraint,+ desc,)from sqlalchemy.ext.asyncio import AsyncAttrsfrom sqlalchemy.orm import DeclarativeBase@@ -476,7 +477,10 @@ class TOTPCodeModel(Base):class ActionModel(Base):__tablename__ = "actions"- __table_args__ = (Index("action_org_task_step_index", "organization_id", "task_id", "step_id"),)+ __table_args__ = (+ Index("action_org_task_step_index", "organization_id", "task_id", "step_id"),+ Index("action_org_created_at_index", "organization_id", desc("created_at")),+ )action_id = Column(String, primary_key=True, index=True, default=generate_action_id)action_type = Column(String, nullable=False)