feat: 自动更新系统 — 版本化迁移引擎 + updater 模块 + CLI + API#60
Merged
Conversation
Introduce a versioned schema migration system replacing the previous idempotent CREATE TABLE approach. Changes: - New migration.rs module with Migration struct, _schema_version tracking - SCHEMA_VERSION constant compiled into binary - Forward migration engine (run_migrations) for both SQLite and PostgreSQL - Backward migration engine (rollback_to) with reverse SQL support - pg_advisory_lock for PostgreSQL multi-instance migration safety - Backward compatibility: auto-detect existing schema as v1 - 5 unit tests covering forward/idempotent/rollback/auto-detect edge cases Design: docs/other/upgrade-strategy.md Tasks: docs/other/auto-update-tasks.md
Phase 4 - Release workflow: - Add easybot-version.json generation step to release.yml - Upload version.json as release artifact, include in release assets Phase 5 - API endpoints: - New GET /api/v1/system/update-check endpoint returning version info - OpenAPI registration for update_check path and UpdateCheckResponse - Add schema_version to health check response - Permission: ConfigRead for update-check (same as /system) - Update insta snapshot for health response schema change
Phase 6 - Integration tests: - Version comparison edge cases (pre-release, invalid, semver) - Platform detection and asset name generation - Migration on temp SQLite DB (forward, verify, data insert) - Migration rollback and re-apply cycle - Backup manifest file read/write roundtrip Phase 7 - Documentation: - CLAUDE.md: Added migration system and updater module docs - Updated: startup version lock, migration lifecycle, upgrade flow
- Task 6.6: GitHub API wiremock tests (4 test cases: latest release, rate limit 403, not found 404, checksums parsing) - Task 6.8: API endpoint test for /api/v1/system/update-check - Task 7.3: Update user-guide.md with upgrade commands section
- Add #[allow(dead_code)] to cfg-gated functions on non-Unix - available_space() on Windows (precheck.rs) - set_executable() on Windows (replace.rs)
fix: address auto-update review issues
…syBot into feature/auto-update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 EasyBot 添加完整的自动更新支持,涵盖版本化数据库迁移、二进制自动更新、CLI 命令和 API 端点。
设计文档
变更清单
Phase 1: 版本化迁移引擎
core/src/storage/migration.rs— Migration 结构体、SCHEMA_VERSION、双后端迁移pg_advisory_lock)Phase 2: Updater 核心模块 (7 files)
Phase 3: CLI 子命令
easybot check-update— 版本对比 + 迁移清单 + breaking changeseasybot update— 预检→确认→下载→替换→验证 (带自动回滚)easybot rollback— 从备份清单恢复Phase 4: Release Workflow
easybot-version.json(含 schema 版本、migration 信息)Phase 5: API 端点
GET /api/v1/system/update-check— 版本检查/health增加schema_version字段测试
使用方式