Skip to content

fix(db): auto-migrate scene_card_json column for existing databases#47

Merged
DankerMu merged 1 commit into
mainfrom
fix/scene-card-migration
Feb 21, 2026
Merged

fix(db): auto-migrate scene_card_json column for existing databases#47
DankerMu merged 1 commit into
mainfrom
fix/scene-card-migration

Conversation

@DankerMu
Copy link
Copy Markdown
Owner

Summary

  • create_all 不会给已有表添加新列,导致已有数据库缺少 scene_card_json
  • 在 lifespan 启动时自动执行 ALTER TABLE 添加缺失列
  • 使用 try/except 忽略列已存在的情况

Test plan

  • 127 后端测试通过
  • 已有数据库加载项目树不再 500
  • 新数据库正常创建列

🤖 Generated with Claude Code

create_all does not ALTER existing tables. Add lightweight column
migration in lifespan to add scene_card_json if missing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DankerMu
Copy link
Copy Markdown
Owner Author

Review: PASS — simple ALTER TABLE migration in lifespan, try/except for idempotency.

@DankerMu DankerMu merged commit 1858f38 into main Feb 21, 2026
7 checks passed
@DankerMu DankerMu deleted the fix/scene-card-migration branch February 21, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant