Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add org index to the actions table #1673

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 ###
6 changes: 5 additions & 1 deletion skyvern/forge/sdk/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
String,
UnicodeText,
UniqueConstraint,
desc,
)
from sqlalchemy.ext.asyncio import AsyncAttrs
from sqlalchemy.orm import DeclarativeBase
Expand Down Expand Up @@ -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)
Expand Down