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

1.6 KiB

Tasks: Config to MySQL

1. 数据模型与配置存储模块

  • 1.1 在 app/models.py 中新增 AppConfig 模型
  • 1.2 创建 app/config_store.py,实现 ConfigStore
  • 1.3 实现 get_config(key) 方法,支持 MySQL → JSON 降级
  • 1.4 实现 set_config(key, value) 方法,支持 MySQL + JSON 双写
  • 1.5 实现 load_from_json(key, fallback) 辅助方法

2. 数据迁移

  • 2.1 创建 app/config_migration.py,实现 migrate_configs_to_mysql()
  • 2.2 在 app/main.py lifespan 中创建 app_config
  • 2.3 在 app/main.py lifespan 中调用迁移函数
  • 2.4 迁移幂等性:数据库已有配置时跳过

3. 修改配置 API

  • 3.1 修改 app/api/config.py 使用 ConfigStore 读写 symbols 配置
  • 3.2 修改 app/api/ai_config.py 使用 ConfigStore 读写 ai 配置
  • 3.3 保持 API 接口签名不变

4. 修改业务使用方

  • 4.1 修改 app/api/futures_analysis.pyConfigStore 读取品种配置
  • 4.2 修改 app/api/trade_review.pyConfigStore 读取品种配置
  • 4.3 修改 app/services/trade_parser.pyConfigStore 读取品种配置
  • 4.4 修改 app/services/plan_generator.pyConfigStore 读取品种配置
  • 4.5 修改 app/services/ai_analysis.pyConfigStore 读取 AI 配置

5. 测试与验证

  • 5.1 编写 tests/test_config_store.py,覆盖 MySQL 命中/未命中/降级场景
  • 5.2 编写迁移测试,验证幂等性
  • 5.3 运行全部测试套件,确保无回归
  • 5.4 启动应用验证配置读取正常