diff --git a/alembic/versions/100_fix_capability_model_bindings.py b/alembic/versions/100_fix_capability_model_bindings.py index 29be5f7ad..c21bfcdc7 100644 --- a/alembic/versions/100_fix_capability_model_bindings.py +++ b/alembic/versions/100_fix_capability_model_bindings.py @@ -23,18 +23,18 @@ def upgrade() -> None: conn = op.get_bind() # 检查表是否存在 - table_check = conn.execute(sa.text("SELECT to_regclass(\public.ai_models\)")).scalar() + table_check = conn.execute(sa.text("SELECT to_regclass('public.ai_models')")).scalar() if not table_check: return - config_table_check = conn.execute(sa.text("SELECT to_regclass(\public.ai_capability_configs\)")).scalar() + config_table_check = conn.execute(sa.text("SELECT to_regclass('public.ai_capability_configs')")).scalar() if not config_table_check: return # 查询目标模型的 ID(使用 model_key 查询,不硬编码 UUID) pro_model_row = conn.execute( sa.text( - "SELECT id FROM ai_models WHERE model_key = \doubao-seed-2-1-pro-260915\ AND deleted_at IS NULL LIMIT 1" + "SELECT id FROM ai_models WHERE model_key = 'doubao-seed-2-1-pro-260915' AND deleted_at IS NULL LIMIT 1" ) ).first() if not pro_model_row: @@ -43,7 +43,7 @@ def upgrade() -> None: # 查询旧模型 ID old_model_row = conn.execute( - sa.text("SELECT id FROM ai_models WHERE model_key = \doubao-seed-1-6-250615\ LIMIT 1") + sa.text("SELECT id FROM ai_models WHERE model_key = 'doubao-seed-1-6-250615' LIMIT 1") ).first() old_model_id = old_model_row[0] if old_model_row else None @@ -66,10 +66,10 @@ def upgrade() -> None: # 更新 image_analysis qwen38_row = conn.execute( - sa.text("SELECT id FROM ai_models WHERE model_key = \qwen3.8-flash\ AND deleted_at IS NULL LIMIT 1") + sa.text("SELECT id FROM ai_models WHERE model_key = 'qwen3.8-flash' AND deleted_at IS NULL LIMIT 1") ).first() qwen37_row = conn.execute( - sa.text("SELECT id FROM ai_models WHERE model_key = \qwen3.7-plus\ AND deleted_at IS NULL LIMIT 1") + sa.text("SELECT id FROM ai_models WHERE model_key = 'qwen3.7-plus' AND deleted_at IS NULL LIMIT 1") ).first() if qwen38_row and qwen37_row: @@ -78,7 +78,7 @@ def upgrade() -> None: current_ia = conn.execute( sa.text( - "SELECT primary_model_id, lite_model_id, fallback_model_id FROM ai_capability_configs WHERE capability_key = \image_analysis" + "SELECT primary_model_id, lite_model_id, fallback_model_id FROM ai_capability_configs WHERE capability_key = 'image_analysis'" ) ).first() @@ -104,12 +104,12 @@ def upgrade() -> None: def downgrade() -> None: conn = op.get_bind() - table_check = conn.execute(sa.text("SELECT to_regclass(\public.ai_models\)")).scalar() + table_check = conn.execute(sa.text("SELECT to_regclass('public.ai_models')")).scalar() if not table_check: return old_model_row = conn.execute( - sa.text("SELECT id FROM ai_models WHERE model_key = \doubao-seed-1-6-250615\ LIMIT 1") + sa.text("SELECT id FROM ai_models WHERE model_key = 'doubao-seed-1-6-250615' LIMIT 1") ).first() if not old_model_row: return