Add new db column - script_blocks.input_fields (#4266)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""add script_blocks.input_fields
|
||||
|
||||
Revision ID: 7ab8e817802a
|
||||
Revises: cf6ae2f5013c
|
||||
Create Date: 2025-12-10 23:56:33.299511+00:00
|
||||
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "7ab8e817802a"
|
||||
down_revision: Union[str, None] = "cf6ae2f5013c"
|
||||
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("script_blocks", sa.Column("input_fields", sa.JSON(), nullable=True))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column("script_blocks", "input_fields")
|
||||
# ### end Alembic commands ###
|
||||
@@ -5149,6 +5149,7 @@ class AgentDB:
|
||||
run_signature: str | None = None,
|
||||
workflow_run_id: str | None = None,
|
||||
workflow_run_block_id: str | None = None,
|
||||
input_fields: list[str] | None = None,
|
||||
) -> ScriptBlock:
|
||||
"""Create a script block."""
|
||||
async with self.Session() as session:
|
||||
@@ -5161,6 +5162,7 @@ class AgentDB:
|
||||
run_signature=run_signature,
|
||||
workflow_run_id=workflow_run_id,
|
||||
workflow_run_block_id=workflow_run_block_id,
|
||||
input_fields=input_fields,
|
||||
)
|
||||
session.add(script_block)
|
||||
await session.commit()
|
||||
@@ -5176,6 +5178,7 @@ class AgentDB:
|
||||
workflow_run_id: str | None = None,
|
||||
workflow_run_block_id: str | None = None,
|
||||
clear_run_signature: bool = False,
|
||||
input_fields: list[str] | None = None,
|
||||
) -> ScriptBlock:
|
||||
async with self.Session() as session:
|
||||
script_block = (
|
||||
@@ -5196,6 +5199,8 @@ class AgentDB:
|
||||
script_block.workflow_run_id = workflow_run_id
|
||||
if workflow_run_block_id is not None:
|
||||
script_block.workflow_run_block_id = workflow_run_block_id
|
||||
if input_fields is not None:
|
||||
script_block.input_fields = input_fields
|
||||
await session.commit()
|
||||
await session.refresh(script_block)
|
||||
return convert_to_script_block(script_block)
|
||||
|
||||
@@ -1052,6 +1052,7 @@ class ScriptBlockModel(Base):
|
||||
run_signature = Column(String, nullable=True)
|
||||
workflow_run_id = Column(String, nullable=True)
|
||||
workflow_run_block_id = Column(String, nullable=True)
|
||||
input_fields = Column(JSON, nullable=True)
|
||||
|
||||
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||
modified_at = Column(DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow, nullable=False)
|
||||
|
||||
@@ -645,6 +645,7 @@ def convert_to_script_block(script_block_model: ScriptBlockModel) -> ScriptBlock
|
||||
run_signature=script_block_model.run_signature,
|
||||
workflow_run_id=script_block_model.workflow_run_id,
|
||||
workflow_run_block_id=script_block_model.workflow_run_block_id,
|
||||
input_fields=script_block_model.input_fields,
|
||||
created_at=script_block_model.created_at,
|
||||
modified_at=script_block_model.modified_at,
|
||||
deleted_at=script_block_model.deleted_at,
|
||||
|
||||
Reference in New Issue
Block a user