gathering-migration

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gathering Migration 🌲🐻🐕

集结式迁移 🌲🐻🐕

The drum echoes through the valleys. The Bear wakes from long slumber, gathering strength for the journey ahead. The Bloodhound sniffs the terrain, understanding every path and connection. Together they move mountains of data safely—nothing lost, nothing broken, everything finding its new home.
鼓声回荡在山谷中。Bear从漫长的沉睡中苏醒,为即将到来的旅程积蓄力量。Bloodhound嗅探地形,熟悉每一条路径与关联。它们携手安全迁移海量数据——无丢失、无损坏,每一份数据都能找到新的归宿。

When to Summon

何时召唤

  • Complex data migrations requiring codebase exploration
  • Moving data between different system architectures
  • Schema changes affecting multiple relationships
  • Migrations requiring careful pathfinding
  • When you need to understand the territory before moving

  • 需要探查代码库的复杂数据迁移
  • 不同系统架构间的数据迁移
  • 影响多关联关系的 schema 变更
  • 需要谨慎规划路径的迁移
  • 需要先了解业务场景再执行的迁移

Grove Tools for This Gathering

本次集结可用的Grove工具

Use
gw
and
gf
throughout. Quick reference for migration work:
bash
undefined
全程使用
gw
gf
工具。迁移工作速查:
bash
undefined

Find migration-related code and schemas

查找与迁移相关的代码和 schema

gf --agent search "table_name" # Find references to affected tables gf --agent db # Find database-related code gf --agent migrations # List existing migration files
gf --agent search "table_name" # 查找受影响表的引用 gf --agent db # 查找数据库相关代码 gf --agent migrations # 列出已有的迁移文件

Commit completed migrations

提交已完成的迁移

gw git ship --write -a -m "feat: migrate description"

---
gw git ship --write -a -m "feat: migrate description"

---

The Gathering

集结流程

SUMMON → ORGANIZE → EXECUTE → VALIDATE → COMPLETE
   ↓         ↲          ↲          ↲          ↓
Receive  Dispatch   Animals    Verify   Migration
Request  Animals    Work       Data     Complete
SUMMON → ORGANIZE → EXECUTE → VALIDATE → COMPLETE
   ↓         ↲          ↲          ↲          ↓
Receive  Dispatch   Animals    Verify   Migration
Request  Animals    Work       Data     Complete

Animals Mobilized

调动的角色

  1. 🐕 Bloodhound — Scout the codebase, understand data relationships
  2. 🐻 Bear — Migrate data with patient strength

  1. 🐕 Bloodhound — 探查代码库,理解数据关联
  2. 🐻 Bear — 以沉稳的力量迁移数据

Phase 1: SUMMON

阶段1:召唤

The drum sounds. The valleys stir...
Receive and parse the request:
Clarify the Migration:
  • What data needs to move?
  • From where to where?
  • Are relationships involved?
  • What's the rollback plan?
Scope Check:
"I'll mobilize a migration gathering for: [migration description]
This will involve:
  • 🐕 Bloodhound scouting the codebase
    • Map data relationships
    • Find all references to affected tables
    • Identify integration points
    • Document current patterns
  • 🐻 Bear migrating the data
    • Backup before moving
    • Transform in batches
    • Validate after each phase
    • Verify complete migration
Proceed with the gathering?"

鼓声响起,山谷开始躁动...
接收并解析需求:
明确迁移内容:
  • 需要迁移哪些数据?
  • 从哪里迁移到哪里?
  • 是否涉及关联关系?
  • 回滚方案是什么?
范围确认:
"我将为以下任务启动集结式迁移:[迁移描述]
本次迁移将包含:
  • 🐕 Bloodhound 探查代码库
    • 绘制数据关联图
    • 查找受影响表的所有引用
    • 识别集成点
    • 记录当前模式
  • 🐻 Bear 执行数据迁移
    • 迁移前备份数据
    • 分批转换数据
    • 每阶段完成后验证
    • 确认迁移完成
是否启动本次集结?"

Phase 2: ORGANIZE

阶段2:组织

The animals prepare for the journey...
Dispatch in sequence:
Dispatch Order:
Bloodhound ──→ Bear
     │            │
     │            │
Scout          Migrate
Territory      Data
Dependencies:
  • Bloodhound must complete before Bear (needs to understand relationships)

角色们为旅程做好准备...
按顺序调动:
调动顺序:
Bloodhound ──→ Bear
     │            │
     │            │
Scout          Migrate
Territory      Data
依赖关系:
  • Bloodhound必须先完成探查,Bear才能开始迁移(需要先理解数据关联)

Phase 3: EXECUTE

阶段3:执行

The paths are known. The migration begins...
Execute each phase:
🐕 BLOODHOUND — SCOUT
"Sniffing out every trail, every connection..."

Phase: SCENT
- Identify source and destination
- Find all tables/collections involved

Phase: TRACK
- Trace foreign key relationships
- Find code that references the data
- Map dependencies

Phase: HUNT
- Deep dive into complex relationships
- Identify orphaned records
- Find edge cases

Phase: REPORT
- Document all findings
- Create relationship diagrams
- List all files that need updates

Phase: RETURN
- Hand off complete map to Bear

Output:
- Data relationship map
- List of affected files
- Migration risk assessment
- Edge case documentation
🐻 BEAR — MIGRATE
"Waking from slumber, moving with strength..."

Phase: WAKE
- Create migration plan
- Set up tools
- Prepare rollback strategy

Phase: GATHER
- Backup all data
- Inventory data quality
- Document row counts

Phase: MOVE
- Transform data in batches
- Handle relationships carefully
- Process in correct order

Phase: HIBERNATE
- Verify row counts match
- Check data integrity
- Validate relationships

Phase: VERIFY
- Application tests pass
- Queries work correctly
- Performance acceptable

Output:
- Migrated data
- Validation reports
- Updated codebase

路径已明确,迁移开始...
分阶段执行:
🐕 BLOODHOUND — 探查
"嗅探每一条轨迹、每一处关联..."

阶段:定位
- 识别数据源与目标端
- 找出所有涉及的表/集合

阶段:追踪
- 追溯外键关联
- 查找引用该数据的代码
- 绘制依赖关系图

阶段:深挖
- 深入分析复杂关联
- 识别孤立记录
- 找出边缘案例

阶段:报告
- 记录所有发现
- 创建关联关系图
- 列出所有需要更新的文件

阶段:交付
- 将完整的关联图交付给Bear

输出:
- 数据关联图
- 受影响文件列表
- 迁移风险评估
- 边缘案例文档
🐻 BEAR — 迁移
"从沉睡中苏醒,沉稳行动..."

阶段:准备
- 制定迁移计划
- 配置工具
- 准备回滚策略

阶段:集结
- 备份所有数据
- 检查数据质量
- 记录行数

阶段:迁移
- 分批转换数据
- 谨慎处理关联关系
- 按正确顺序处理

阶段:校验
- 确认行数匹配
- 检查数据完整性
- 验证关联关系

阶段:验证
- 应用测试通过
- 查询正常运行
- 性能符合要求

输出:
- 已迁移的数据
- 验证报告
- 更新后的代码库

Phase 4: VALIDATE

阶段4:验证

The journey ends. Both animals confirm safe arrival...
Validation Checklist:
  • Bloodhound: All relationships mapped
  • Bloodhound: All references found
  • Bloodhound: Edge cases documented
  • Bear: Backup created and verified
  • Bear: Row counts match (source vs dest)
  • Bear: Data integrity checks pass
  • Bear: Foreign keys intact
  • Bear: Application tests pass
  • Bear: Rollback tested
Data Quality Checks:
sql
-- Row count validation
SELECT
  (SELECT COUNT(*) FROM old_table) as source_count,
  (SELECT COUNT(*) FROM new_table) as dest_count;

-- Should be equal

-- Foreign key integrity
SELECT COUNT(*) as orphaned_records
FROM child_table c
LEFT JOIN parent_table p ON c.parent_id = p.id
WHERE p.id IS NULL;

-- Should be 0

-- Data sampling
SELECT * FROM new_table
ORDER BY RANDOM()
LIMIT 10;

-- Spot check transformation logic

旅程结束,两个角色确认数据安全抵达...
验证清单:
  • Bloodhound:所有关联关系已绘制
  • Bloodhound:所有引用已找到
  • Bloodhound:边缘案例已记录
  • Bear:已创建并验证备份
  • Bear:源端与目标端行数匹配
  • Bear:数据完整性检查通过
  • Bear:外键完整
  • Bear:应用测试通过
  • Bear:回滚方案已测试
数据质量检查:
sql
-- 行数验证
SELECT
  (SELECT COUNT(*) FROM old_table) as source_count,
  (SELECT COUNT(*) FROM new_table) as dest_count;

-- 结果应相等

-- 外键完整性检查
SELECT COUNT(*) as orphaned_records
FROM child_table c
LEFT JOIN parent_table p ON c.parent_id = p.id
WHERE p.id IS NULL;

-- 结果应为0

-- 数据抽样
SELECT * FROM new_table
ORDER BY RANDOM()
LIMIT 10;

-- 抽查转换逻辑

Phase 5: COMPLETE

阶段5:完成

The gathering ends. Data rests in its new home...
Completion Report:
markdown
undefined
集结结束,数据在新归宿安顿...
完成报告:
markdown
undefined

🌲 GATHERING MIGRATION COMPLETE

🌲 集结式迁移完成

Migration: [Description]

迁移任务:[描述]

Animals Mobilized

调动的角色

🐕 Bloodhound → 🐻 Bear
🐕 Bloodhound → 🐻 Bear

Territory Mapped (Bloodhound)

探查结果(Bloodhound)

  • Tables affected: [count]
  • Relationships found: [count]
  • Code files referencing data: [count]
  • Edge cases identified: [list]
  • 受影响表数量:[count]
  • 发现的关联关系:[count]
  • 引用数据的代码文件:[count]
  • 识别的边缘案例:[list]

Data Moved (Bear)

迁移结果(Bear)

  • Records migrated: [count]
  • Duration: [time]
  • Batches processed: [count]
  • Errors encountered: [count]
  • 迁移记录数:[count]
  • 耗时:[time]
  • 处理的批次:[count]
  • 遇到的错误数:[count]

Validation Results

验证结果

  • Row count match: ✅ [source] = [dest]
  • Data integrity: ✅
  • Foreign keys: ✅
  • Application tests: ✅ [X/Y passing]
  • Performance: ✅
  • 行数匹配:✅ [source] = [dest]
  • 数据完整性:✅
  • 外键:✅
  • 应用测试:✅ [X/Y通过]
  • 性能:✅

Rollback Status

回滚状态

  • Backup retained at: [location]
  • Rollback tested: ✅
  • Rollback time: [estimated]
  • 备份存储位置:[location]
  • 回滚已测试:✅
  • 预估回滚时间:[estimated]

Files Updated

更新的文件

  • Migration scripts: [files]
  • Application code: [files]
  • Documentation: [files]
  • 迁移脚本:[files]
  • 应用代码:[files]
  • 文档:[files]

Time Elapsed

总耗时

[Duration]
The data has found its new home. 🌲

---
[Duration]
数据已找到新归宿。 🌲

---

Example Gathering

集结示例

User: "/gathering-migration Move user preferences from users table to separate table"
Gathering execution:
  1. 🌲 SUMMON — "Mobilizing for: Split user preferences. Move theme, notifications from users table to user_preferences table."
  2. 🌲 ORGANIZE — "Bloodhound scouts → Bear migrates"
  3. 🌲 EXECUTE
    • 🐕 Bloodhound: "Found 15,423 users. 234 have theme set. 12 have notifications disabled. Referenced in dashboard, settings, 3 API routes."
    • 🐻 Bear: "Backup created. Migrated in 16 batches. All rows accounted for. FK constraints maintained."
  4. 🌲 VALIDATE — "15,423 source = 15,423 dest. No orphans. All tests pass."
  5. 🌲 COMPLETE — "Preferences migrated. Code updated. Backup retained."

Every piece of data arrived safely. 🌲
用户: "/gathering-migration 将用户偏好从users表迁移至独立表"
集结执行过程:
  1. 🌲 召唤 — "启动集结任务:拆分用户偏好。将主题、通知设置从users表迁移至user_preferences表。"
  2. 🌲 组织 — "Bloodhound先行探查 → Bear执行迁移"
  3. 🌲 执行
    • 🐕 Bloodhound:"发现15,423位用户。234位用户设置了主题。12位用户禁用了通知。数据被仪表盘、设置页面及3个API路由引用。"
    • 🐻 Bear:"已创建备份。分16批次完成迁移。所有行数已核对。外键约束已维护。"
  4. 🌲 验证 — "源端15,423条 = 目标端15,423条。无孤立记录。所有测试通过。"
  5. 🌲 完成 — "用户偏好迁移完成。代码已更新。备份已留存。"

每一份数据都安全抵达。 🌲