database-migration-helper
Skill0 starsChanged 2 months agoMITView on GitHub
Guides agents through writing safe, zero-downtime, expand-and-contract database schema migrations without locking tables.
In this repository49 other files it gives its agents.
- bug-reproducerSkill
- claim-checkerSkill
- command-failure-diagnoserSkill
- config-risk-reviewerSkill
- csv-validatorSkill
- deployment-checklist-makerSkill
- diff-reviewerSkill
- factual-summarizerSkill
- field-extractorSkill
- api-contract-testerSkill
- security-vulnerability-fixerSkill
- git-commit-stagerSkill
- git-conflict-resolverSkill
- github-actions-debuggerSkill
- github-issue-triagerSkill
- github-pr-creatorSkill
- github-pr-reviewerSkill
- go-code-qualitySkill
- go-lint-and-vetSkill
- go-testingSkill
- json-schema-converterSkill
- lint-and-typecheckSkill
- meaning-preserving-editorSkill
- meeting-notes-to-actionsSkill
- minimal-bug-fixSkill
- option-comparatorSkill
- py-code-qualitySkill
- py-lint-and-typecheckSkill
- py-testingSkill
- readme-writerSkill
- regression-test-writerSkill
- release-notes-drafterSkill
- repo-inspectorSkill
- research-briefSkill
- reversible-cleanup-plannerSkill
- rust-clippy-checkSkill
- rust-code-qualitySkill
- rust-testingSkill
- small-refactorSkill
- status-updateSkill
- step-by-step-tutorialSkill
- step-decomposerSkill
- tabular-analyzerSkill
- task-briefSkill
- test-runner-debuggerSkill
- ts-code-qualitySkill
- ts-lint-and-typecheckSkill
- ts-testingSkill
- skill-templateSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 7 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use this skill when:
- Very specific: line 20
Do not use for CSV file validation.
- Very specific: line 27
If migration framework is unknown: inspect repository for prisma/, alembic/, migrations/.
- Distinctive: line 28
Never author a migration that drops a column in the same release old code is running.
- Distinctive: line 31
Follow these numbered actions:
- Distinctive: line 37
Write non-blocking SQL/ORM migration script.
- Distinctive: line 39
Write reversible rollback statement.
- Very specific: line 45
Never set NOT NULL without a default on an existing populated table.
- Distinctive: line 78
Stop and ask the user when:
- Distinctive: line 102
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_users_last_login_at ON users (last_login_at).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Migration Helper
Authors safe, backward-compatible database schema migrations. Enforces the "Expand and Contract" pattern, non-blocking column additions, and safe index creation.
1. Purpose
Prevent database outages and lockups during schema updates.
2. When to Use
Use this skill when:
- Adding, renaming, or dropping database columns.
- Adding indexes in production PostgreSQL/MySQL without locking writes.
- Writing migration files (Prisma, TypeORM, Alembic, Django, Flyway, Goose).
3. When Not to Use
- Do not use for CSV file validation; use
csv-validator.
4. Required Inputs
table_name: Target database table.schema_change: Proposed modification (e.g. "Add email_verified boolean column").
5. Missing-Input Behavior
- If migration framework is unknown: inspect repository for
prisma/,alembic/,migrations/. - Never author a migration that drops a column in the same release old code is running.
6. Procedure
Follow these numbered actions:
- Action 1: Identify Migration Pattern
- Adding column: Must be nullable or have a default value.
- Renaming column: Add new column, dual-write, backfill, drop old in subsequent release.
- Adding index: Use
CREATE INDEX CONCURRENTLYin Postgres.
- Action 2: Author Up Migration
- Write non-blocking SQL/ORM migration script.
- Action 3: Author Down (Rollback) Migration
- Write reversible rollback statement.
- Action 4: Emit Migration Plan
- Format per Section 8.
7. Decision Rules
- In PostgreSQL: never run
CREATE INDEXwithoutCONCURRENTLYon high-traffic tables. - Never set
NOT NULLwithout a default on an existing populated table.
8. Output Format
Emit the report using this template:
### Database Migration Plan: [Table Name]
- **Framework**: [Prisma | Alembic | Raw SQL | Goose]
- **Migration Name**: `[e.g. 20260910_add_verified_to_users]`
- **Lock Risk**: [LOW (Zero-downtime) | HIGH (Table lock)]
#### Migration UP
```sql
[Safe SQL Migration]Migration DOWN (Rollback)
[Rollback SQL]
## 9. Verification Checklist
- [ ] New column is nullable or has default value.
- [ ] Indexes created concurrently.
- [ ] Rollback statement verified.
## 10. Common Failures and Recovery
| Failure Symptom | Cause | Recovery Action |
| :--- | :--- | :--- |
| Table locked for 30 minutes | `CREATE INDEX` without `CONCURRENTLY` | Add `CONCURRENTLY` keyword and run outside transaction. |
## 11. Stop or Escalation Conditions
Stop and ask the user when:
- Migration requires table-rewriting locks on tables with millions of rows.
## 12. Examples
### Example 1: Successful Execution
**Input:**
```text
Table: users
Change: Add last_login_at timestamp
DB: PostgreSQLOutput:
### Database Migration Plan: users
- **Framework**: PostgreSQL SQL
- **Migration Name**: `20260910_add_last_login_at_to_users`
- **Lock Risk**: LOW (Zero-downtime)
#### Migration UP
```sql
ALTER TABLE users ADD COLUMN last_login_at TIMESTAMPTZ NULL;
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_users_last_login_at ON users (last_login_at);Migration DOWN (Rollback)
DROP INDEX CONCURRENTLY IF EXISTS idx_users_last_login_at;
ALTER TABLE users DROP COLUMN IF EXISTS last_login_at;
### Example 2: Ambiguous or Missing Input
**Input:**
```text
Change database.Output:
### Database Migration Plan: Halted - Missing Details
- **Status**: Halted
Please provide the target table name and proposed column changes.Example 3: Expected Final Output
Output:
### Database Migration Plan: orders
- **Framework**: PostgreSQL SQL
- **Migration Name**: `20260910_add_status_index`
- **Lock Risk**: LOWDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

