feat: add sync checkpoint restore for last successful sync

Capture rolling online DB snapshots after push/drain/reconcile and expose SyncPage 数据恢复 plus checkpoint/restore APIs; mark Z12h and restore done in coop docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-08-06 11:49:00 +08:00
parent 75622a728e
commit 680d2b8cde
11 changed files with 860 additions and 16 deletions

View File

@@ -99,6 +99,19 @@ Binding`POST /api/v1/admin/sync/bindings` 登记 `local_database_id → onlin
**空表也要两侧建齐**:本机空表 → `POST .../schema/ensure`;线上空表 → `POST .../schema`(或 pull 的 `columns`)在本机 `CREATE IF NOT EXISTS`。仅靠 outbox 行 push **不会**带上空表。
控制台「查看线上表」可 **删表**`POST .../admin/sync/channels/{id}/drop-table`):只删当前查看侧,**不同步** `DROP` 到另一侧;本机仍有同名表时下次 push/ensure 可能再建回来。
## 数据恢复(恢复上次同步 · 已落实)
成功同步后agent **自动/手动 push**、通道 drain、控制台「同步修复」平台对**线上库**打滚动快照(`latest` + `previous`,约 30 秒防抖)。
| 操作 | 说明 |
|------|------|
| SyncPage「数据恢复」 | 将线上库恢复为所选快照(写入快照行,并删除快照中不存在的行) |
| 本机 | 平台不直连宇恒 SQLite恢复线上后终端下次同步/指纹 pull 可从线上补回 |
| 无快照 | 部署后须先完成至少一次成功同步;按钮会提示「尚无成功同步快照」 |
| 误删后又自动同步成功 | 最新快照可能已含删除后状态 → 确认框选「上一代」 |
API`GET .../admin/sync/channels/{id}/checkpoint``POST .../admin/sync/channels/{id}/restore``confirm=true``which=latest|previous`)。详见联调意见 §5.13。
## 谁能看什么
| 角色 | 可见 |