You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
buffer_platform/openspec/changes/config-to-mysql/tasks.md

38 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Tasks: Config to MySQL
## 1. 数据模型与配置存储模块
- [x] 1.1 在 `app/models.py` 中新增 `AppConfig` 模型
- [x] 1.2 创建 `app/config_store.py`,实现 `ConfigStore`
- [x] 1.3 实现 `get_config(key)` 方法,支持 MySQL → JSON 降级
- [x] 1.4 实现 `set_config(key, value)` 方法,支持 MySQL + JSON 双写
- [x] 1.5 实现 `_load_json(key, fallback)``_save_to_json(key, value)` 辅助方法
## 2. 数据迁移
- [x] 2.1 创建 `app/config_migration.py`,实现 `migrate_configs_to_mysql()`
- [x] 2.2 在 `app/main.py` lifespan 中创建 `app_config`
- [x] 2.3 在 `app/main.py` lifespan 中调用迁移函数
- [x] 2.4 迁移幂等性:数据库已有配置时跳过
## 3. 修改配置 API
- [x] 3.1 修改 `app/api/config.py` 使用 `ConfigStore` 读写 `symbols` 配置
- [x] 3.2 修改 `app/api/ai_config.py` 使用 `ConfigStore` 读写 `ai` 配置
- [x] 3.3 保持 API 接口签名不变
## 4. 修改业务使用方
- [x] 4.1 修改 `app/api/futures_analysis.py``ConfigStore` 读取品种配置
- [x] 4.2 修改 `app/api/trade_review.py``ConfigStore` 读取品种配置
- [x] 4.3 修改 `app/services/trade_parser.py``ConfigStore` 读取品种配置
- [x] 4.4 修改 `app/services/plan_generator.py``ConfigStore` 读取品种配置
- [x] 4.5 修改 `app/services/ai_analysis.py``ConfigStore` 读取 AI 配置
## 5. 测试与验证
- [x] 5.1 编写 `tests/test_config_store.py`,覆盖 MySQL 命中/未命中/降级场景
- [x] 5.2 编写迁移测试,验证幂等性
- [x] 5.3 运行全部测试套件确保无回归110 passed, 2 xfailed
- [x] 5.4 启动应用验证配置读取正常