From 4e290bd80a5a3ddf697d8148516fa4010aadd74a Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Wed, 5 Aug 2026 13:11:55 +0800 Subject: [PATCH] storage: add UploadSessions columns for server-proxied upload metadata The server-proxied upload flow (replaces presign-PUT) stores the file-level metadata directly on the UploadSessions row at session creation, so step 2 (PUT bytes) can build the StorageObjects row without re-sending metadata through a separate CompleteUploadRequest. New columns on upload_sessions: file_name VARCHAR(255) NOT NULL DEFAULT '' usage_type VARCHAR(32) NOT NULL DEFAULT 'working_copy' visibility VARCHAR(16) NOT NULL DEFAULT 'private' is_immutable TINYINT(1) NOT NULL DEFAULT 0 The SQLAlchemy model already declares these columns; this migration applies the schema change to MySQL. Migration: c3d4e5f6a7b8_upload_session_object_metadata.py (chains off a2b3c4d5e6f7) --- ...e5f6a7b8_upload_session_object_metadata.py | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 migrations/versions/c3d4e5f6a7b8_upload_session_object_metadata.py diff --git a/migrations/versions/c3d4e5f6a7b8_upload_session_object_metadata.py b/migrations/versions/c3d4e5f6a7b8_upload_session_object_metadata.py new file mode 100644 index 0000000..63e9ea2 --- /dev/null +++ b/migrations/versions/c3d4e5f6a7b8_upload_session_object_metadata.py @@ -0,0 +1,73 @@ +"""add object metadata columns to upload_sessions + +Stores file_name / usage_type / visibility / is_immutable at session creation +so the server-proxied PUT step can build the StorageObjects row without +re-sending them. Replaces the old CompleteUploadRequest payload that bridged +the presign-PUT and head()-validate steps. + +Revision ID: c3d4e5f6a7b8 +Revises: a2b3c4d5e6f7 +Create Date: 2026-08-05 12:00:00 +""" + +from collections.abc import Sequence + +from alembic import op +import sqlalchemy as sa + + +revision: str = "c3d4e5f6a7b8" +down_revision: str | Sequence[str] | None = "a2b3c4d5e6f7" +branch_labels: str | Sequence[str] | None = None +depends_on: str | Sequence[str] | None = None + + +def upgrade() -> None: + op.add_column( + "upload_sessions", + sa.Column( + "file_name", + sa.String(length=255), + nullable=False, + server_default="", + ), + ) + op.add_column( + "upload_sessions", + sa.Column( + "usage_type", + sa.String(length=32), + nullable=False, + server_default="working_copy", + comment=( + "data_resource/version_artifact/snapshot/run_log/run_result/" + "working_copy/public_script" + ), + ), + ) + op.add_column( + "upload_sessions", + sa.Column( + "visibility", + sa.String(length=16), + nullable=False, + server_default="private", + comment="private/workspace/public", + ), + ) + op.add_column( + "upload_sessions", + sa.Column( + "is_immutable", + sa.TINYINT(1), + nullable=False, + server_default="0", + ), + ) + + +def downgrade() -> None: + op.drop_column("upload_sessions", "is_immutable") + op.drop_column("upload_sessions", "visibility") + op.drop_column("upload_sessions", "usage_type") + op.drop_column("upload_sessions", "file_name") \ No newline at end of file