postgres-database-migration
包含风险评估与实操建议,是 DBA 与运维团队必备的迁移指南。
在生产上运行模式变更可能导致锁表或数据异常
规划、测试并安全执行 PostgreSQL 模式迁移,降低生产风险。
在生产库做 PostgreSQL 模式变更时,帮你评估风险、设计测试流程并给出安全执行步骤,降低对大表的锁定和上线风险。适合新增/重命名/改类型列、加删索引或约束、设计零停机迁移和回滚策略时使用。特点是把 ALTER TABLE 的锁级别、阻塞风险、回滚方案和在分支环境用真数据测试的建议都讲清楚。
▸ 展开 SKILL.md 英文原文
Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. **Trigger when user asks to:** - Test a schema migration before applying it to production - Add, remove, or rename columns safely on a live table - Change a column's data type without downtime - Add or drop indexes, constraints, or foreign keys on large tables - Understand which ALTER TABLE operations lock the table - Roll back a failed migration - Plan a zero-downtime migration strategy - Fork a database to test a migration safely **Keywords:** migration, schema change, ALTER TABLE, add column, drop column, rename column, change type, zero downtime, lock, AccessExclusiveLock, concurrent index, forking, ghost, rollback, backfill, deploy Covers: lock-level reference for every common DDL operation, safe migration patterns, fork-based testing, zero-downtime column changes, index creation, constraint addition, backfill strategies, pr
帮我安装这个 skill:https://raw.githubusercontent.com/timescale/pg-aiguide/main/skills/postgres-database-migration/SKILL.mdcurl -fsSL "https://raw.githubusercontent.com/timescale/pg-aiguide/main/skills/postgres-database-migration/SKILL.md"# PostgreSQL Database Migrations A schema migration that works on an empty dev database can fail, lock, or corrupt data on a production table with millions of rows. This guide covers how to assess risk, test against real data, and execute migrations safely. ## DDL Lock Reference Every schema change acquires a lock. The critical question is: **does it block reads and writes, and for how long?** ### Fast, Non-Blocking Operations These complete in milliseconds regardless of table size. They only hold a brief `AccessExclusiveLock` for the catalog update, not for data rewriting. | Operation | Lock Level | Notes | |-----------|-----------|-------| | `ADD COLUMN` (nullable, no default) | `Acc