add script blocks table (#3125)
This commit is contained in:
@@ -0,0 +1,47 @@
|
|||||||
|
"""add script_blocks table
|
||||||
|
|
||||||
|
Revision ID: 92d665af080e
|
||||||
|
Revises: d67d7c00ab02
|
||||||
|
Create Date: 2025-08-08 21:05:52.563372+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "92d665af080e"
|
||||||
|
down_revision: Union[str, None] = "d67d7c00ab02"
|
||||||
|
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_table(
|
||||||
|
"script_blocks",
|
||||||
|
sa.Column("script_block_id", sa.String(), nullable=False),
|
||||||
|
sa.Column("script_id", sa.String(), nullable=False),
|
||||||
|
sa.Column("script_revision_id", sa.String(), nullable=False),
|
||||||
|
sa.Column("script_block_label", sa.String(), nullable=False),
|
||||||
|
sa.Column("script_file_id", sa.String(), nullable=False),
|
||||||
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||||
|
sa.Column("modified_at", sa.DateTime(), nullable=False),
|
||||||
|
sa.Column("deleted_at", sa.DateTime(), nullable=True),
|
||||||
|
sa.PrimaryKeyConstraint("script_block_id"),
|
||||||
|
sa.UniqueConstraint(
|
||||||
|
"script_revision_id", "script_block_label", name="uc_script_revision_id_script_block_label"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
op.create_index(op.f("ix_script_blocks_script_revision_id"), "script_blocks", ["script_revision_id"], unique=False)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index(op.f("ix_script_blocks_script_revision_id"), table_name="script_blocks")
|
||||||
|
op.drop_table("script_blocks")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -48,6 +48,7 @@ PERSISTENT_BROWSER_SESSION_ID = "pbs"
|
|||||||
SCRIPT_FILE_PREFIX = "sf"
|
SCRIPT_FILE_PREFIX = "sf"
|
||||||
SCRIPT_REVISION_PREFIX = "sr"
|
SCRIPT_REVISION_PREFIX = "sr"
|
||||||
SCRIPT_PREFIX = "s"
|
SCRIPT_PREFIX = "s"
|
||||||
|
SCRIPT_BLOCK_PREFIX = "sb"
|
||||||
STEP_PREFIX = "stp"
|
STEP_PREFIX = "stp"
|
||||||
TASK_GENERATION_PREFIX = "tg"
|
TASK_GENERATION_PREFIX = "tg"
|
||||||
TASK_PREFIX = "tsk"
|
TASK_PREFIX = "tsk"
|
||||||
@@ -227,6 +228,11 @@ def generate_script_file_id() -> str:
|
|||||||
return f"{SCRIPT_FILE_PREFIX}_{int_id}"
|
return f"{SCRIPT_FILE_PREFIX}_{int_id}"
|
||||||
|
|
||||||
|
|
||||||
|
def generate_script_block_id() -> str:
|
||||||
|
int_id = generate_id()
|
||||||
|
return f"{SCRIPT_BLOCK_PREFIX}_{int_id}"
|
||||||
|
|
||||||
|
|
||||||
############# Helper functions below ##############
|
############# Helper functions below ##############
|
||||||
def generate_id() -> int:
|
def generate_id() -> int:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ from skyvern.forge.sdk.db.id import (
|
|||||||
generate_organization_bitwarden_collection_id,
|
generate_organization_bitwarden_collection_id,
|
||||||
generate_output_parameter_id,
|
generate_output_parameter_id,
|
||||||
generate_persistent_browser_session_id,
|
generate_persistent_browser_session_id,
|
||||||
|
generate_script_block_id,
|
||||||
generate_script_file_id,
|
generate_script_file_id,
|
||||||
generate_script_id,
|
generate_script_id,
|
||||||
generate_script_revision_id,
|
generate_script_revision_id,
|
||||||
@@ -861,3 +862,24 @@ class WorkflowScriptModel(Base):
|
|||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
deleted_at = Column(DateTime, nullable=True)
|
deleted_at = Column(DateTime, nullable=True)
|
||||||
|
|
||||||
|
|
||||||
|
class ScriptBlockModel(Base):
|
||||||
|
__tablename__ = "script_blocks"
|
||||||
|
__table_args__ = (
|
||||||
|
UniqueConstraint(
|
||||||
|
"script_revision_id",
|
||||||
|
"script_block_label",
|
||||||
|
name="uc_script_revision_id_script_block_label",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
script_block_id = Column(String, primary_key=True, default=generate_script_block_id)
|
||||||
|
script_id = Column(String, nullable=False)
|
||||||
|
script_revision_id = Column(String, nullable=False, index=True)
|
||||||
|
script_block_label = Column(String, nullable=False)
|
||||||
|
script_file_id = Column(String, nullable=False)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user