Files
dukang/deploy/测试数据清理.md
T
jacy 7304c7a8e1 chore(ops): 增加生产库备份/回滚与按 isTest 清理脚本
只入库通用运维能力,不提交写死手机号的一次性清理脚本与 dump。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-23 22:03:35 +08:00

15 lines
855 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 测试数据清理(通用)
按 HQ 白名单 + `isTest` 打标清理,**不写死手机号/订单号**。dump 落在 `deploy/backups/`(已 gitignore)。
## 流程
1. 备份:`bash deploy/backup-prod-db.sh --yes`;建议同时在 RDS 控制台打手动快照
2. 同步到本地演练:`bash deploy/sync-prod-db-to-local.sh --yes`
3. 盘点(默认本地 `.env`):`pnpm --dir server/dukang-api inventory:test-data`
4. 本地 dry-run / apply`pnpm --dir server/dukang-api cleanup:test-data`,确认后加 `--apply --yes`
5. 生产须口头允许后再执行:`bash deploy/run-prod-cleanup.sh`dry-run)→ `--apply --yes`
6. 回滚:`bash deploy/restore-prod-db.sh --yes backups/prod-<库名>-<时间>.sql`
已打款且混有测试流水时需 `--force`。有交叉风险(测试合伙人下仍有正式门店等)会中止。