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 workflow_permanent_id and version to workflows table #308

Merged
merged 2 commits into from
May 14, 2024
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,32 @@
"""Add workflow_permanent_id and version to workflows table

Revision ID: bf561125112f
Revises: 8792454ce498
Create Date: 2024-05-14 01:14:15.024575+00:00

"""
from typing import Sequence, Union

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "bf561125112f"
down_revision: Union[str, None] = "8792454ce498"
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.add_column("workflows", sa.Column("workflow_permanent_id", sa.String(), nullable=True))
op.add_column("workflows", sa.Column("version", sa.Integer(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("workflows", "version")
op.drop_column("workflows", "workflow_permanent_id")
# ### end Alembic commands ###
6 changes: 6 additions & 0 deletions skyvern/forge/sdk/db/id.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
STEP_PREFIX = "stp"
ARTIFACT_PREFIX = "a"
WORKFLOW_PREFIX = "w"
WORKFLOW_PERMANENT_ID_PREFIX = "wpid"
WORKFLOW_RUN_PREFIX = "wr"
WORKFLOW_PARAMETER_PREFIX = "wp"
AWS_SECRET_PARAMETER_PREFIX = "asp"
Expand All @@ -46,6 +47,11 @@ def generate_workflow_id() -> str:
return f"{WORKFLOW_PREFIX}_{int_id}"


def generate_workflow_permanent_id() -> str:
int_id = generate_id()
return f"{WORKFLOW_PERMANENT_ID_PREFIX}_{int_id}"


def generate_workflow_run_id() -> str:
int_id = generate_id()
return f"{WORKFLOW_RUN_PREFIX}_{int_id}"
Expand Down
4 changes: 4 additions & 0 deletions skyvern/forge/sdk/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
generate_task_id,
generate_workflow_id,
generate_workflow_parameter_id,
generate_workflow_permanent_id,
generate_workflow_run_id,
)
from skyvern.forge.sdk.schemas.tasks import ProxyLocation
Expand Down Expand Up @@ -132,6 +133,9 @@ class WorkflowModel(Base):
modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False)
deleted_at = Column(DateTime, nullable=True)

workflow_permanent_id = Column(String, default=generate_workflow_permanent_id)
version = Column(Integer, default=1)


class WorkflowRunModel(Base):
__tablename__ = "workflow_runs"
Expand Down
Loading