Jon/sky 5803 create workflow scripts table (#3120)

This commit is contained in:
Jonathan Dobson
2025-08-06 15:49:44 -04:00
committed by GitHub
parent 173e8e0670
commit 60ad36f839
3 changed files with 94 additions and 0 deletions

View File

@@ -59,6 +59,7 @@ WORKFLOW_PERMANENT_ID_PREFIX = "wpid"
WORKFLOW_PREFIX = "w"
WORKFLOW_RUN_BLOCK_PREFIX = "wrb"
WORKFLOW_RUN_PREFIX = "wr"
WORKFLOW_SCRIPT_PREFIX = "ws"
def generate_workflow_id() -> str:
@@ -81,6 +82,11 @@ def generate_workflow_run_id() -> str:
return f"{WORKFLOW_RUN_PREFIX}_{int_id}"
def generate_workflow_script_id() -> str:
int_id = generate_id()
return f"{WORKFLOW_SCRIPT_PREFIX}_{int_id}"
def generate_aws_secret_parameter_id() -> str:
int_id = generate_id()
return f"{AWS_SECRET_PARAMETER_PREFIX}_{int_id}"

View File

@@ -50,6 +50,7 @@ from skyvern.forge.sdk.db.id import (
generate_workflow_permanent_id,
generate_workflow_run_block_id,
generate_workflow_run_id,
generate_workflow_script_id,
)
from skyvern.forge.sdk.schemas.task_v2 import ThoughtType
@@ -828,3 +829,34 @@ class ProjectFileModel(Base):
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False)
deleted_at = Column(DateTime, nullable=True)
class WorkflowScriptModel(Base):
__tablename__ = "workflow_scripts"
__table_args__ = (
UniqueConstraint(
"workflow_permanent_id",
"cache_key_value",
name="uc_workflow_permanent_id_cache_key_value",
),
Index("idx_workflow_scripts_org_created", "organization_id", "created_at"),
Index("idx_workflow_scripts_workflow_permanent_id", "workflow_permanent_id"),
)
workflow_script_id = Column(String, primary_key=True, default=generate_workflow_script_id)
script_id = Column(String, nullable=False)
organization_id = Column(String, nullable=False)
workflow_permanent_id = Column(String, nullable=False)
workflow_id = Column(String, nullable=True)
workflow_run_id = Column(String, nullable=True)
cache_key = Column(String, nullable=False) # e.g. "test-{{ website_url }}-cache"
cache_key_value = Column(String, nullable=False) # e.g. "test-greenhouse.io/job/1-cache"
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
modified_at = Column(
DateTime,
default=datetime.datetime.utcnow,
onupdate=datetime.datetime.utcnow,
nullable=False,
)
deleted_at = Column(DateTime, nullable=True)