feat(api): Add model for workflow suspension
parent
74981a65c6
commit
838630c39e
@ -0,0 +1,28 @@
|
||||
from enum import StrEnum
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from libs.uuid_utils import uuidv7
|
||||
|
||||
|
||||
class StateVersion(StrEnum):
|
||||
# `V1` is `GraphRuntimeState` serialized as JSON by dumping with Pydantic.
|
||||
V1 = "v1"
|
||||
|
||||
|
||||
class WorkflowSuspension(BaseModel):
|
||||
id: UUID = Field(default_factory=uuidv7)
|
||||
|
||||
# Correspond to WorkflowExecution.id_
|
||||
execution_id: str
|
||||
|
||||
workflow_id: str
|
||||
|
||||
continuation_node_id: str
|
||||
|
||||
state: str
|
||||
|
||||
state_version: StateVersion = StateVersion.V1
|
||||
|
||||
inputs: str
|
||||
@ -0,0 +1,51 @@
|
||||
"""Add WorkflowSuspension model, add suspension_id to WorkflowRun
|
||||
|
||||
Revision ID: 1091956b9ee0
|
||||
Revises: 1c9ba48be8e4
|
||||
Create Date: 2025-07-17 20:20:43.710683
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import models as models
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1091956b9ee0'
|
||||
down_revision = '1c9ba48be8e4'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('workflow_suspensions',
|
||||
sa.Column('id', models.types.StringUUID(), server_default=sa.text('uuidv7()'), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
|
||||
sa.Column('tenant_id', models.types.StringUUID(), nullable=False),
|
||||
sa.Column('app_id', models.types.StringUUID(), nullable=False),
|
||||
sa.Column('workflow_id', models.types.StringUUID(), nullable=False),
|
||||
sa.Column('workflow_run_id', models.types.StringUUID(), nullable=False),
|
||||
sa.Column('resumed_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('continuation_node_id', sa.String(length=255), nullable=False),
|
||||
sa.Column('state_version', sa.String(length=20), nullable=False),
|
||||
sa.Column('state', sa.Text(), nullable=False),
|
||||
sa.Column('inputs', sa.Text(), nullable=True),
|
||||
sa.Column('form_code', sa.String(length=32), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id', name=op.f('workflow_suspensions_pkey')),
|
||||
sa.UniqueConstraint('form_code', name=op.f('workflow_suspensions_form_code_key'))
|
||||
)
|
||||
with op.batch_alter_table('workflow_runs', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('suspension_id', models.types.StringUUID(), nullable=True))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('workflow_runs', schema=None) as batch_op:
|
||||
batch_op.drop_column('suspension_id')
|
||||
|
||||
op.drop_table('workflow_suspensions')
|
||||
# ### end Alembic commands ###
|
||||
Loading…
Reference in New Issue