Add archer import and allow date-mode bulk delete

archer import replays a sealed archive into an existing table: shard
selection (`--select`), SHA-256 pre-verification, idempotent modes
(`ignore`/`insert`/`replace`), and both LOAD DATA and batched-INSERT
engines. It reads manifest.jsonl strictly so corruption is reported
instead of skipped, and supports --dry-run, --allow-partial, and
per-shard workers.

--bulk-delete no longer rejects --shard-by date. Range deletion now
derives its bounds from the chunk's actual keys (date scanners rewrite
LastKey into a resumption cursor) and keeps safe-auto-increment
semantics by excluding the current max key. A startup warning documents
the monotonic-shard-column assumption.

Also splits CLI/format/sharding/progress/safety reference docs out of
the README, and adds the corresponding OpenSpec change artifacts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
voidandClaude Sonnet 4.6 committed 2026-11-08 21:14:23 +08:00
1 parent bc4a6b504f
commit 366d61ca25
49 files changed
+5099 -342

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
# 快速开始
## 要求
- Go 1.24+(构建)
- MySQL 5.7+ / 8.0 或 MariaDB 10.x(运行)
- 源表必须有主键或唯一索引;日期分片还需要分片列上的索引(见[分片模式](sharding.md))
## 构建
```bash
go build -o archer ./cmd/archer
```
或使用打包脚本(Windows PowerShell / Linux shell):
```powershell
./scripts/build.ps1
```
```bash
./scripts/build.sh
```
产物在 `dist/` 下,版本信息通过 `-ldflags -X` 注入,`archer --version` 可查看。
## 最小示例
```bash
archer \
--source 'user:pass@tcp(10.0.0.5:3306)/app' \
--table orders \
--where "created_at < '2025-01-01'" \
--file ./export \
--format dump
```
结果:`./export/000001.<首主键>-<尾主键>.dump`、`manifest.jsonl`、`state.json`。
只写目标表:
```bash
archer --source '...' --table orders --where "id < 100000" \
--dest 'user:pass@tcp(10.0.0.9:3306)/archive' --dest-table orders
```
只删除(危险,需确认):
```bash
archer --source '...' --table orders --where "created_at < '2024-01-01'" --purge
```
先看计划,不落盘:
```bash
archer --source '...' --table orders --where "1=1" --file /tmp/out --dry-run
```
## 下一步
- [分片模式](sharding.md)
- [输出格式与导入](output-formats.md)
- [清单与断点](checkpoint-and-resume.md)
- [进度显示](progress.md)
- [安全说明](safety.md)
- [参数参考](cli-reference.md)