Files
HuiBrain/alembic/env.py
EduBrain Dev b17786b57b feat: v1.2.0 - 图片去重与管理、微信机器人优化、搜索设置可配置
主要功能:
- 图片上传时 OCR 内容去重(3个上传端点统一使用公共函数 _check_ocr_duplicate)
- 图片管理 Tab:展示所有图片、手动删除、一键去重
- 搜索结果详情弹窗增加删除按钮(带确认弹窗)
- 图片管理卡片点击查看详情(复用 showOcrDetailModal)
- 搜索限制和 LLM 批量判断数量可通过网站设置
- MiniMax API 调用添加 reasoning_split=True
- 企业微信机器人:WebSocket 长连接、图片搜索、配置化搜索数量
- 版本号升级至 1.2.0
2026-04-13 22:25:08 +08:00

68 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Alembic 迁移环境配置
支持异步数据库连接
"""
from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
# 导入所有 ORM 模型以确保 Base.metadata 包含完整的表定义
from app.models.base import Base
# Alembic Config 对象
config = context.config
# 设置日志
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# 元数据目标,用于自动生成迁移
target_metadata = Base.metadata
def run_migrations_offline() -> None:
"""
'offline' 模式运行迁移。
只需要 URL不需要 Engine。调用 context.execute() 将迁移
直接发送到数据库。
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
"""
'online' 模式运行迁移。
创建 Engine 并关联 connection 到 context。
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=target_metadata,
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()