add status column to the workflow_scripts table (#3450)
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
"""add status to the workflow_scripts table; update idx_workflow_scripts_wpid_cache_key_value index
|
||||||
|
|
||||||
|
Revision ID: 67add341e926
|
||||||
|
Revises: 8998d998feed
|
||||||
|
Create Date: 2025-09-17 14:58:20.282185+00:00
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "67add341e926"
|
||||||
|
down_revision: Union[str, None] = "8998d998feed"
|
||||||
|
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("workflow_scripts", sa.Column("status", sa.String(), nullable=True, server_default="published"))
|
||||||
|
op.drop_index(op.f("idx_workflow_scripts_wpid_cache_key_value"), table_name="workflow_scripts")
|
||||||
|
op.create_index(
|
||||||
|
"idx_workflow_scripts_wpid_cache_key_value",
|
||||||
|
"workflow_scripts",
|
||||||
|
["workflow_permanent_id", "cache_key_value", "workflow_run_id"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_index("idx_workflow_scripts_wpid_cache_key_value", table_name="workflow_scripts")
|
||||||
|
op.create_index(
|
||||||
|
op.f("idx_workflow_scripts_wpid_cache_key_value"),
|
||||||
|
"workflow_scripts",
|
||||||
|
["workflow_permanent_id", "cache_key_value"],
|
||||||
|
unique=False,
|
||||||
|
)
|
||||||
|
op.drop_column("workflow_scripts", "status")
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -893,7 +893,9 @@ class WorkflowScriptModel(Base):
|
|||||||
__tablename__ = "workflow_scripts"
|
__tablename__ = "workflow_scripts"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
Index("idx_workflow_scripts_org_created", "organization_id", "created_at"),
|
Index("idx_workflow_scripts_org_created", "organization_id", "created_at"),
|
||||||
Index("idx_workflow_scripts_wpid_cache_key_value", "workflow_permanent_id", "cache_key_value"),
|
Index(
|
||||||
|
"idx_workflow_scripts_wpid_cache_key_value", "workflow_permanent_id", "cache_key_value", "workflow_run_id"
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
workflow_script_id = Column(String, primary_key=True, default=generate_workflow_script_id)
|
workflow_script_id = Column(String, primary_key=True, default=generate_workflow_script_id)
|
||||||
@@ -904,6 +906,7 @@ class WorkflowScriptModel(Base):
|
|||||||
workflow_run_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 = 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"
|
cache_key_value = Column(String, nullable=False) # e.g. "test-greenhouse.io/job/1-cache"
|
||||||
|
status = Column(String, nullable=True, default="published")
|
||||||
|
|
||||||
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
created_at = Column(DateTime, default=datetime.datetime.utcnow, nullable=False)
|
||||||
modified_at = Column(
|
modified_at = Column(
|
||||||
|
|||||||
@@ -154,3 +154,8 @@ class ScriptBlocksResponse(BaseModel):
|
|||||||
class ScriptBlocksRequest(BaseModel):
|
class ScriptBlocksRequest(BaseModel):
|
||||||
cache_key_value: str
|
cache_key_value: str
|
||||||
cache_key: str | None = None
|
cache_key: str | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class ScriptStatus(StrEnum):
|
||||||
|
published = "published"
|
||||||
|
draft = "draft"
|
||||||
|
|||||||
Reference in New Issue
Block a user