deepelementlab/clawcode/database-migrations
Claude Code and agent skill by deepelementlab/clawcode
- community
Checking that the SKILL.md file is still in the repository.
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs (Prisma, Drizzle, Django, TypeORM, golang-migrate).
Install
npx vskill@latest install deepelementlab/clawcode/database-migrationsSKILL.md
The same SKILL.md was published earlier as deepelementlab/jupyter-studio/database-migrations.
Database Migration Patterns
Safe, reversible database schema changes for production systems.
When to Activate
- Creating or altering database tables
- Adding/removing columns or indexes
- Running data migrations (backfill, transform)
- Planning zero-downtime schema changes
- Setting up migration tooling for a new project
Core Principles
- Every change is a migration — never alter production databases manually
- Migrations are forward-only in production — rollbacks use new forward migrations
- Schema and data migrations are separate — never mix DDL and DML in one migration
- Test migrations against production-sized data — a migration that works on 100 rows may lock on 10M
- Migrations are immutable once deployed — never edit a migration that has run in production
Migration Safety Checklist
Before applying any migration:
- [ ] Migration has both UP and DOWN (or is explicitly marked irreversible)
- [ ] No full table locks on large tables (use concurrent operations)
- [ ] New columns have defaults or are nullable (never add NOT NULL without default)
- [ ] Indexes created concurrently (not inline with CREATE TABLE for existing tables)
- [ ] Data backfill is a separate migration from schema change
- [ ] Tested against a copy of production data
- [ ] Rollback plan documented
PostgreSQL Patterns
Adding a Column Safely
Adding an Index Without Downtime
Renaming a Column (Zero-Downtime)
Never rename directly in production. Use the expand-contract pattern:
Removing a Column Safely
Large Data Migrations
Prisma (TypeScript/Node.js)
Workflow
Schema Example
Custom SQL Migration
For operations Prisma cannot express (concurrent indexes, data backfills):
Drizzle (TypeScript/Node.js)
Workflow
Schema Example
Django (Python)
Workflow
Data Migration
SeparateDatabaseAndState
Remove a column from the Django model without dropping it from the database immediately:
golang-migrate (Go)
Workflow
Migration Files
Zero-Downtime Migration Strategy
For critical production changes, follow the expand-contract pattern:
Timeline Example
Anti-Patterns
| Anti-Pattern | Why It Fails | Better Approach | |
|---|---|---|---|
| Manual SQL in production | No audit trail, unrepeatable | Always use migration files | |
| Editing deployed migrations | Causes drift between environments | Create new migration instead | |
| NOT NULL without default | Locks table, rewrites all rows | Add nullable, backfill, then add constraint | |
| Inline index on large table | Blocks writes during build | CREATE INDEX CONCURRENTLY | |
| Schema + data in one migration | Hard to rollback, long transactions | Separate migrations | |
| Dropping column before removing code | Application errors on missing column | Remove code first, drop column next deploy |
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingclawcode/plugin/builtin_plugins/clawcode-skills/skills/database-migrations/SKILL.md
Popularity
- Repository stars
- 126
- Repository forks
- 46
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/deepelementlab/clawcode/database-migrations)