From 58dfae60f063825bc65239e26a593655ae03b70c Mon Sep 17 00:00:00 2001 From: QuantumGhost Date: Tue, 12 Aug 2025 16:03:02 +0800 Subject: [PATCH] feat(api): Add migration for WorkflowDraftVariableFile --- ...b8b6ed8f1_add_workflowdraftvariablefile.py | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 api/migrations/versions/2025_08_12_1601-76db8b6ed8f1_add_workflowdraftvariablefile.py diff --git a/api/migrations/versions/2025_08_12_1601-76db8b6ed8f1_add_workflowdraftvariablefile.py b/api/migrations/versions/2025_08_12_1601-76db8b6ed8f1_add_workflowdraftvariablefile.py new file mode 100644 index 0000000000..fd18c3761c --- /dev/null +++ b/api/migrations/versions/2025_08_12_1601-76db8b6ed8f1_add_workflowdraftvariablefile.py @@ -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 ###