mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 15:17:39 +08:00
feat(api): Add migration for WorkflowDraftVariableFile
This commit is contained in:
parent
de08b2310c
commit
58dfae60f0
@ -0,0 +1,92 @@
|
|||||||
|
"""add WorkflowDraftVariableFile
|
||||||
|
|
||||||
|
Revision ID: 76db8b6ed8f1
|
||||||
|
Revises: 532b3f888abf
|
||||||
|
Create Date: 2025-08-12 16:01:40.318520
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import models as models
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "76db8b6ed8f1"
|
||||||
|
down_revision = "fa8b0fa6f407"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table(
|
||||||
|
"workflow_draft_variable_files",
|
||||||
|
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(
|
||||||
|
"tenant_id",
|
||||||
|
models.types.StringUUID(),
|
||||||
|
nullable=False,
|
||||||
|
comment="The application to which the WorkflowDraftVariableFile belongs, referencing App.id",
|
||||||
|
),
|
||||||
|
sa.Column(
|
||||||
|
"app_id",
|
||||||
|
models.types.StringUUID(),
|
||||||
|
nullable=False,
|
||||||
|
comment="The application to which the WorkflowDraftVariableFile belongs, referencing App.id",
|
||||||
|
),
|
||||||
|
sa.Column(
|
||||||
|
"user_id",
|
||||||
|
models.types.StringUUID(),
|
||||||
|
nullable=False,
|
||||||
|
comment="The owner to of the WorkflowDraftVariableFile, referencing Account.id",
|
||||||
|
),
|
||||||
|
sa.Column(
|
||||||
|
"upload_file_id",
|
||||||
|
models.types.StringUUID(),
|
||||||
|
nullable=False,
|
||||||
|
comment="Reference to UploadFile containing the large variable data",
|
||||||
|
),
|
||||||
|
sa.Column("size", sa.BigInteger(), nullable=False, comment="Size of the original variable content in bytes"),
|
||||||
|
sa.Column(
|
||||||
|
"length",
|
||||||
|
sa.Integer(),
|
||||||
|
nullable=True,
|
||||||
|
comment=(
|
||||||
|
"Length of the original variable content. For array and array-like types, this represents the "
|
||||||
|
"number of elements. For object types, it indicates the number of keys. For other types, "
|
||||||
|
"the value is NULL."
|
||||||
|
)
|
||||||
|
),
|
||||||
|
sa.Column("value_type", sa.String(20), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint("id", name=op.f("workflow_draft_variable_files_pkey")),
|
||||||
|
)
|
||||||
|
with op.batch_alter_table("workflow_draft_variables", schema=None) as batch_op:
|
||||||
|
batch_op.add_column(
|
||||||
|
sa.Column(
|
||||||
|
"file_id",
|
||||||
|
models.types.StringUUID(),
|
||||||
|
nullable=True,
|
||||||
|
comment="Reference to WorkflowDraftVariableFile if variable is offloaded to external storage",
|
||||||
|
)
|
||||||
|
sa.sa.Column(
|
||||||
|
"is_default_value",
|
||||||
|
sa.Boolean,
|
||||||
|
nullable=False
|
||||||
|
server_default=sa.false(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
batch_op.create_index("workflow_draft_variable_file_id_idx", ["file_id"], unique=False)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table("workflow_draft_variables", schema=None) as batch_op:
|
||||||
|
batch_op.drop_column("file_id")
|
||||||
|
|
||||||
|
op.drop_table("workflow_draft_variable_files")
|
||||||
|
# ### end Alembic commands ###
|
||||||
Loading…
Reference in New Issue
Block a user