AGENT SKILL
SQL 数据库迁移
sql-migrations
SQL 与数据库迁移最佳实践,用于安全地变更数据库模式(schema)。
- License 许可
- MIT
- 最近更新
- 2026-11-05
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- sql-migrations
- license
- MIT
- metadata
- { "author": "shahboura", "version": "2.0.0", "audience": "developers", "workflow": "development" }
- description
- SQL and database migration best practices for safe schema changes
- compatibility
- opencode
03 SKILL.md 正文
What I do
- Enforce safe migration patterns with rollback support
- Apply schema design rules for constraints, indexes, and data integrity
- Guide destructive change management and data backfill strategies
When to use me
Use this when writing database migrations, schema changes, or data transformation scripts.
Key Rules
- Migrations must be idempotent where possible; always provide down/rollback steps
- Never drop data or tables without explicit approval and confirmed backups
- Use explicit versions or timestamps; keep migration order deterministic
- Stage destructive changes (drops, renames) separately from data moves — never in the same migration
- Test migrations against a prod-like snapshot before deploying to production
- Declare explicit column types and constraints: PK, FK, UNIQUE, CHECK, NOT NULL on every column
- Add indexes for join columns and common filter predicates; avoid over-indexing
- Wrap DDL statements in transactions when the database supports it; guard against lock escalation on large tables
- Always include
WHEREclauses on UPDATE and DELETE — never allow unintended full-table changes - Use UTC timezone and consistent collation/charset across the entire schema
- Backfill data in batches — never use single massive statements that lock tables
- Avoid
SELECT *in views and procedures; specify columns explicitly - Avoid long-running blocking migrations during peak traffic; prefer phased rollouts
- Use a verify-fix-verify loop: run the validation commands below, fix any failures, and rerun until all checks pass
Validation Commands
sqlfluff lint
04 同仓库更多 Skills
Python 编程开发
python
暂无简介
★ 2
文档有效性校验
docs-validation
暂无简介
★ 2
Python 编程开发
python
暂无简介
★ 2
文档有效性校验
docs-validation
暂无简介
★ 2
Python 编程开发
python
暂无简介
★ 2
文档校验
docs-validation
暂无简介
★ 2