Files
Aether/_deprecated_py_src/alembic/versions/README.md
fawney19 1d9c77522a refactor: 移除 Python 后端源码,全面迁移至 Rust gateway 架构
- 删除全部 Python 源码 (src/) 及 Alembic 迁移脚本,归档至 _deprecated_py_src/
- 重构 Rust gateway ai_pipeline: 拆分 planner/finalize 模块,新增 contracts/adaptation 层
- 重组 handlers 模块为 admin/public/proxy/internal/shared 子模块结构
- 新增 executor 模块,引入 Rust 原生数据库迁移 (aether-data/migrations)
- 简化 CI/Docker 构建流程,移除 base image 二级构建,统一为单一 app image
- 移除 Python 相关基础设施文件 (entrypoint.sh, gunicorn_conf.py, Dockerfile.base)
2026-04-03 16:26:16 +08:00

2.2 KiB
Raw Blame History

Aether - 数据库迁移说明

当前版本

  • Revision ID: aether_baseline
  • 创建日期: 2025-12-06
  • 状态: 全新基线

迁移历史

所有历史增量迁移已清理,当前以完整 schema 作为新起点。

核心数据库结构

用户系统

  • users: 用户账户管理
  • api_keys: API 密钥管理
  • wallets: 统一钱包账户(充值余额/赠款余额/无限制模式)
  • user_preferences: 用户偏好设置

Provider 三层架构

  • providers: LLM 提供商配置
  • provider_endpoints: Provider 的 API 端点配置
  • provider_api_keys: Endpoint 的具体 API 密钥
  • api_key_provider_mappings: 用户 API Key 到 Provider 的映射关系

模型系统

  • global_models: 统一模型定义GlobalModel
  • models: Provider 的模型实现和价格配置
  • model_mappings: 统一的别名与降级映射表

监控和追踪

  • usage: API 使用记录
  • request_candidates: 请求候选记录
  • provider_usage_tracking: Provider 使用统计
  • audit_logs: 系统审计日志

系统功能

  • announcements: 系统公告
  • announcement_reads: 公告阅读记录
  • system_configs: 系统配置

从旧数据库迁移

如需从旧数据库迁移数据,请使用迁移脚本:

# 设置环境变量
export OLD_DATABASE_URL="postgresql://user:pass@old-host:5432/old_db"
export NEW_DATABASE_URL="postgresql://user:pass@new-host:5432/aether"

# 干运行(查看迁移量)
python scripts/migrate_data.py --dry-run

# 执行迁移
python scripts/migrate_data.py

# 只迁移特定表
python scripts/migrate_data.py --tables users,providers,api_keys

# 跳过大表
python scripts/migrate_data.py --skip usage,audit_logs

新数据库初始化

# 1. 运行迁移创建表结构
DATABASE_URL="postgresql://user:pass@host:5432/aether" uv run alembic upgrade head

# 2. 初始化管理员账户
python -m src.database.init_db

未来迁移

基于 aether_baseline 创建增量迁移:

# 修改模型后,生成新的迁移
DATABASE_URL="..." uv run alembic revision --autogenerate -m "描述变更"

# 应用迁移
DATABASE_URL="..." uv run alembic upgrade head