06ec0ee202
后端: - 新增 BGM 数据库模型、Schema、CRUD、API 路由 - BgmMusic 增加 url 字段存储七牛云地址 - Alembic 迁移: 创建 BGM 表 + 添加 url 字段 - import_bgm.py 导入时自动上传七牛云 (meijiaka-zy/bgm/...) 前端: - VideoCompose BGM 选择改为卡片弹窗 (系统BGM + 本地上传) - 去掉 BGM 硬编码本地路径, 直接使用云端 URL - CoverDesign 视觉重构: 绿色边框卡片、角标、hover 遮罩 - CoverDesign 去掉预选背景, 默认空白需手动选择 - 所有步骤按钮规范统一: 左=重新生成(主色), 右=导出/预览(次色) - 预览按钮状态统一: 文字变为'视频预览中...', 保持 btn-secondary - 去掉所有步骤按钮的 svg/emoji 图标 Rust: - mix_bgm_to_video 支持临时文件保护 (输入输出同路径时自动中转) - FFmpeg BGM 混合使用 aloop 循环 + amix 滤镜
87 lines
2.4 KiB
Python
87 lines
2.4 KiB
Python
"""
|
|
Alembic 环境配置 - PostgreSQL
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from logging.config import fileConfig
|
|
|
|
from sqlalchemy import engine_from_config, pool
|
|
|
|
from alembic import context
|
|
|
|
# 添加项目路径
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
|
|
|
# 加载环境变量
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
# 导入模型
|
|
from app.db.session import Base
|
|
from app.models.bgm_music import BgmMusic # noqa
|
|
from app.models.broll_category import BrollCategory # noqa
|
|
from app.models.broll_material import BrollMaterial # noqa
|
|
from app.models.broll_tag import BrollTag # noqa
|
|
from app.models.cover_background import CoverBackground # noqa
|
|
from app.models.point_batch import PointBatch # noqa
|
|
from app.models.point_recharge_order import PointRechargeOrder # noqa
|
|
from app.models.point_transaction import PointTransaction # noqa
|
|
from app.models.update import AppRelease, ReleasePackage # noqa
|
|
from app.models.user import User # noqa
|
|
from app.models.user_device import UserDevice # noqa
|
|
from app.models.user_point import UserPoint # noqa
|
|
|
|
# this is the Alembic Config object
|
|
config = context.config
|
|
|
|
# 从环境变量读取数据库 URL
|
|
database_url = os.getenv("DATABASE_URL")
|
|
if database_url:
|
|
# 将 asyncpg 转换为 psycopg2 用于 alembic (同步)
|
|
sync_database_url = database_url.replace("+asyncpg", "")
|
|
config.set_main_option("sqlalchemy.url", sync_database_url)
|
|
|
|
# 设置日志
|
|
if config.config_file_name is not None:
|
|
fileConfig(config.config_file_name)
|
|
|
|
# 模型元数据
|
|
target_metadata = Base.metadata
|
|
|
|
|
|
def run_migrations_offline() -> None:
|
|
"""Run migrations in 'offline' mode."""
|
|
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:
|
|
"""Run migrations in 'online' mode."""
|
|
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()
|