把事务回滚描述成“安全测试”忽略了 ALTER TABLE 的生产锁风险
原文依据:2 处指导将 `BEGIN; ALTER TABLE...; ROLLBACK;` 表述为安全测试,但事务回滚只能撤销大多数结构变化,不能避免 `ALTER TABLE` 获取强锁、阻塞其他会话或执行耗时扫描。主文件又明确把该 Skill 用于在线数据库变更。
若在繁忙的生产数据库中测试,操作即使最终回滚,也可能阻塞读写、堆积连接并造成服务超时。
主文件明确将在线、无停机的数据库变更纳入用途,而详细指导把可回滚事务称为“安全测试”。回滚能撤销多数 DDL 结果,但可见内容没有提醒 `ALTER TABLE` 仍可能获取强锁、阻塞会话或进行耗时工作。因此在生产库照做存在可用性风险。用户可要求作者补充锁级别、超时、预演和维护窗口条件。
- Deciding whether and how to partition a large table, or how to store semi-structured data.- Planning a schema change on a live database without downtime.查看另外 1 个位置
### Safe schema evolution- **Transactional DDL**: most DDL operations can run in transactions and be rolled back—`BEGIN; ALTER TABLE...; ROLLBACK;` for safe testing.- **Concurrent index creation**: `CREATE INDEX CONCURRENTLY` avoids blocking writes but can't run in transactions.- **Volatile defaults cause rewrites**: adding `NOT NULL` columns with volatile defaults (e.g., `now()`, `gen_random_uuid()`) rewrites entire table. Non-volatile defaults are fast.