postgres-database-migration

仓库创建 2025年7月24日最近提交 1 个月前SkillHot 收录 20 天前
▸ 精选理由

包含风险评估与实操建议,是 DBA 与运维团队必备的迁移指南。

▸ 风险提示

在生产上运行模式变更可能导致锁表或数据异常

这个 Skill 做什么

规划、测试并安全执行 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

开发编程迁移PostgreSQL安全变更通用
1.8k
Stars
99
Forks
10
仓库内 Skill
+13
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/timescale/pg-aiguide/main/skills/postgres-database-migration/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/timescale/pg-aiguide/main/skills/postgres-database-migration/SKILL.md"
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
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有