From 25979625288036177ba1373c4e2ffed0a688f158 Mon Sep 17 00:00:00 2001 From: Xiaoxia Agent Date: Tue, 6 Oct 2026 01:03:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(vision):=20097=20migration=E8=A3=B8SQL?= =?UTF-8?q?=E7=94=A8sa.text()=E5=8C=85=E8=A3=B9=EF=BC=88SQLAlchemy=202.x?= =?UTF-8?q?=E8=A6=81=E6=B1=82=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../097_viral_video_image_analysis_v4.py | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/alembic/versions/097_viral_video_image_analysis_v4.py b/alembic/versions/097_viral_video_image_analysis_v4.py index 7f7750b1a..37cb8e4a3 100644 --- a/alembic/versions/097_viral_video_image_analysis_v4.py +++ b/alembic/versions/097_viral_video_image_analysis_v4.py @@ -11,6 +11,8 @@ 统一置为 inactive。 """ +import sqlalchemy as sa + from alembic import op revision = "097_viral_video_image_analysis_v4" @@ -30,16 +32,18 @@ def upgrade() -> None: conn = op.get_bind() existing = conn.execute( - "SELECT id FROM viral_video_prompt_templates " "WHERE prompt_type = 'image_analysis' AND version = :v", + sa.text("SELECT id FROM viral_video_prompt_templates " "WHERE prompt_type = 'image_analysis' AND version = :v"), {"v": V4_VERSION}, ).fetchone() if existing is None: conn.execute( - "INSERT INTO viral_video_prompt_templates " - "(name, prompt_type, version, system_prompt, user_prompt_template, " - "example_output, is_active) " - "VALUES (:name, 'image_analysis', :version, :sys, :user, :example, TRUE)", + sa.text( + "INSERT INTO viral_video_prompt_templates " + "(name, prompt_type, version, system_prompt, user_prompt_template, " + "example_output, is_active) " + "VALUES (:name, 'image_analysis', :version, :sys, :user, :example, TRUE)" + ), { "name": V4_NAME, "version": V4_VERSION, @@ -50,9 +54,11 @@ def upgrade() -> None: ) else: conn.execute( - "UPDATE viral_video_prompt_templates SET name = :name, " - "system_prompt = :sys, user_prompt_template = :user, " - "example_output = :example, is_active = TRUE WHERE id = :id", + sa.text( + "UPDATE viral_video_prompt_templates SET name = :name, " + "system_prompt = :sys, user_prompt_template = :user, " + "example_output = :example, is_active = TRUE WHERE id = :id" + ), { "name": V4_NAME, "sys": V4_SYSTEM_PROMPT, @@ -63,8 +69,10 @@ def upgrade() -> None: ) conn.execute( - "UPDATE viral_video_prompt_templates SET is_active = FALSE " - "WHERE prompt_type = 'image_analysis' AND version <> :v", + sa.text( + "UPDATE viral_video_prompt_templates SET is_active = FALSE " + "WHERE prompt_type = 'image_analysis' AND version <> :v" + ), {"v": V4_VERSION}, ) @@ -72,10 +80,12 @@ def upgrade() -> None: def downgrade() -> None: conn = op.get_bind() conn.execute( - "DELETE FROM viral_video_prompt_templates " "WHERE prompt_type = 'image_analysis' AND version = :v", + sa.text("DELETE FROM viral_video_prompt_templates " "WHERE prompt_type = 'image_analysis' AND version = :v"), {"v": V4_VERSION}, ) conn.execute( - "UPDATE viral_video_prompt_templates SET is_active = TRUE " - "WHERE prompt_type = 'image_analysis' AND version = 1" + sa.text( + "UPDATE viral_video_prompt_templates SET is_active = TRUE " + "WHERE prompt_type = 'image_analysis' AND version = 1" + ) )