Skip to content

fix: 修复备份时缺失的人格文件夹映射#5042

Merged
Soulter merged 1 commit intoAstrBotDevs:masterfrom
xzj0898:fix_backup_persona
Feb 12, 2026
Merged

fix: 修复备份时缺失的人格文件夹映射#5042
Soulter merged 1 commit intoAstrBotDevs:masterfrom
xzj0898:fix_backup_persona

Conversation

@xzj0898
Copy link
Contributor

@xzj0898 xzj0898 commented Feb 11, 2026

修复备份功能中 MAIN_DB_MODELS 遗漏 persona_folders 表映射的问题,该问题导致备份文件缺失文件夹表数据,进而引发 personas 表的 folder_id 无法匹配到对应的文件夹数据,破坏了数据关联完整性。
fix #5027

Modifications / 改动点

  1. constants.pyMAIN_DB_MODELS 字典中补充 persona_folders 表与 PersonaFolder 模型的映射关系,确保备份时能导出该表数据;
  2. 导入缺失的 PersonaFolder 类。
  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

代码变更后,备份压缩包main_db.json新增了以下字段(示例),原本无persona_folders

"persona_folders": [
    {
      "id": 1,
      "name": "test",
      "description": null,
      "folder_id": "737cacc0-e053-4b2a-ae3d-a62dbeea403c",
      "created_at": "2026-02-11T13:34:34.338254",
      "updated_at": "2026-02-11T13:34:34.338262",
      "parent_id": null,
      "sort_order": 0
    }
  ],
新版本导入数据 前端也可正常显示文件夹及文件夹下人格 ---

Checklist / 检查清单

  • 😊 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。/ If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • 👀 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。/ My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
  • 🤓 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到了 requirements.txtpyproject.toml 文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
  • 😮 我的更改没有引入恶意代码。/ My changes do not introduce malicious code.

Summary by Sourcery

错误修复:

  • persona_folders 表加入 MAIN_DB_MODELS,以便备份文件包含与 personas 关联的文件夹数据。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Include the persona_folders table in MAIN_DB_MODELS so backup files contain folder data linked to personas.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Feb 11, 2026
@dosubot
Copy link

dosubot bot commented Feb 11, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些总体反馈:

  • 鉴于这次遗漏很容易被忽视,建议考虑将 MAIN_DB_MODELS 集中化管理,或从单一可信来源(例如 SQLAlchemy 的元数据或共享注册表)中自动生成,从而降低未来新增表在备份中被遗漏的风险。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Since this omission was easy to miss, consider centralizing or generating `MAIN_DB_MODELS` from a single source of truth (e.g., SQLAlchemy metadata or a shared registry) to reduce the chances of future tables being left out of backups.

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎帮忙分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • Since this omission was easy to miss, consider centralizing or generating MAIN_DB_MODELS from a single source of truth (e.g., SQLAlchemy metadata or a shared registry) to reduce the chances of future tables being left out of backups.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since this omission was easy to miss, consider centralizing or generating `MAIN_DB_MODELS` from a single source of truth (e.g., SQLAlchemy metadata or a shared registry) to reduce the chances of future tables being left out of backups.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the area:core The bug / feature is about astrbot's core, backend label Feb 11, 2026
@Soulter Soulter merged commit 4af064f into AstrBotDevs:master Feb 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]导入备份后人格与人格文件夹被隐藏,出现计数正确但列表不展示的异常。

2 participants