跳到主内容
@wquguru
精选82VoxAI 产品与模型

npx claude-code-templates:避免迁移锁表冻结

Nobody warns Claude Code users about this part.

原文
发到 X
推荐理由

这篇把“会卡住的具体场景”讲清楚,并用子代理的工作流拆解了怎么避免表锁,还提供了可复述的测试对比与安装命令,写法对同行参考价值高。

Nobody warns Claude Code users about this part.

没有人会提醒 Claude Code 的用户注意这一部分。

Simply put, you ask Claude to add a column or build an index on a table with tens of millions of rows. The migration runs, 𝘁𝗵𝗲 𝘄𝗵𝗼𝗹𝗲 𝘁𝗮𝗯𝗹𝗲 𝗴𝗲𝘁𝘀 𝗹𝗼𝗰𝗸𝗲𝗱, and your live app freezes with it.

简单来说,你让 Claude 在一个拥有数千万行数据的表上添加一列或创建索引。迁移运行时,𝘁𝗵𝗲 𝘄𝗵𝗼𝗹𝗲 𝘁𝗮𝗯𝗹𝗲 𝗴𝗲𝘁𝘀 𝗹𝗼𝗰𝗸𝗲𝗱,并且你的线上应用会因此卡死。

Install a subagent that only handles databases. Every time you change the database, it: - reads your existing schema and past migrations first - flags changes that would lock tables or break your live app - rewrites them so nothing gets locked and your app keeps running through the deploy - runs the migration on a temporary database before handing it back

安装一个只处理数据库的子智能体。每次你更改数据库,它都会: - 先读取你现有的架构以及之前的迁移 - 标记那些会锁表或导致你的线上应用出问题的变更 - 重新编写它们,确保不会发生锁定,并且在部署过程中你的应用仍能继续运行 - 在交回之前,先在临时数据库上运行迁移

The person who rewrote this subagent tested it: an 80M-row table, 10 minutes before deploy. Same prompt: 𝟲/𝟭𝟬 𝘄𝗶𝘁𝗵𝗼𝘂𝘁 𝗶𝘁, 𝟭𝟬/𝟭𝟬 𝘄𝗶𝘁𝗵 𝗶𝘁. In 8 tests, Claude called it on its own all 8 times.

重写这个子智能体的人对它进行了测试:一个 80M 行的表,在部署前 10 分钟。相同的提示:𝟲/𝟭𝟬 𝘄𝗶𝘁𝗵𝗼𝘂𝘁 𝗶𝘁,𝟭𝟬/𝟭𝟬 𝘄𝗶𝘁𝗵 𝗶𝘁。在 8 次测试中,Claude 自己会在全部 8 次里调用它。

One command to install 👇 npx claude-code-templates@latest --agent database/database-architect

一条命令来安装 👇 npx claude-code-templates@latest --agent database/database-architect

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件