shennawardana23/skillme/database-migrations
Claude Code and agent skill by shennawardana23/skillme
- community
Checking that the SKILL.md file is still in the repository.
Guides safe, reversible PostgreSQL schema and data migrations using golang-migrate, Prisma, Drizzle, or Django migrations. Use when creating or altering tables, adding or removing columns or indexes, planning a zero-downtime schema change, or reviewing a migration before it runs against production. For tables partitioned by hotel_id, use the postgres-hotel-partitioning skill alongside this one.
Install
npx vskill@latest install shennawardana23/skillme/database-migrationsSKILL.md
The same SKILL.md was published earlier as shennawardana23/skillme/database-migrations.
Database Migrations
Every schema change is a migration file, never a manual psql session against production. Migrations are forward-only once deployed — a mistake is fixed with a new migration, not by editing or deleting the one that ran.
Core rules
- Schema changes (DDL) and data backfills (DML) are separate
migrations — mixing them makes a migration slow, lock-prone, and hard to roll back independently.
NOT NULLon a new column requires a default, or a nullable column
followed by a backfill and a later constraint migration — adding NOT NULL with no default to an existing table locks it for a full rewrite.
- Indexes on existing tables use
CREATE INDEX CONCURRENTLY— a plain
CREATE INDEX blocks writes for the duration of the build.
- Test migrations against a production-sized copy, not a 100-row dev
database — lock duration and rewrite cost scale with table size, and a migration that's instant at 100 rows can lock for minutes at 10M.
Zero-downtime pattern (expand → migrate → contract)
Renaming a column in production always goes through this pattern — never a direct ALTER TABLE ... RENAME COLUMN on a table any running application code still references by the old name.
Go (golang-migrate) — this org's default
Gotchas
CREATE INDEX CONCURRENTLYcannot run inside a transaction block — most
migration tools wrap each migration in a transaction by default, so this needs explicit non-transactional handling (golang-migrate's -x flag behavior varies by driver; verify your tool's specific mechanism before relying on it).
- For any table partitioned by
hotel_id, a migration that adds an index
or constraint must apply it per-partition awareness — see postgres-hotel-partitioning for the specific patterns; a migration written as if the table were unpartitioned can silently miss partitions created after the migration ran.
- Large batch backfills should use
LIMIT+FOR UPDATE SKIP LOCKEDin a
loop with periodic COMMIT, not a single unbounded UPDATE — the latter holds one long transaction and locks the table for its full duration.
Real-world grounding
GitLab's 2017 production incident: an engineer, attempting to fix replication lag, ran rm -rf against what they believed was the secondary database directory but was actually production — and every one of the five backup mechanisms in place (regular backups, disk snapshots, LVM snapshots, S3 backups, and a separate replica) had been silently failing or misconfigured for weeks, discovered only when the team tried to actually restore from one. The lesson isn't "have backups" — it's that a backup strategy that has never been tested with an actual restore is not a backup strategy, it's an assumption.
Verification
- [ ] Migration has both an up and a down (or is explicitly irreversible, documented as such)
- [ ] No
NOT NULLadded to an existing table without a default - [ ] Indexes on existing tables use
CONCURRENTLY - [ ] Schema change and data backfill are separate migrations
- [ ] Tested against production-sized data, not a small dev sample
- [ ] hotel_id-partitioned tables checked against
postgres-hotel-partitioning
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/database-migrations/SKILL.md
Popularity
- Repository stars
- 2
- 7-day trend score
- 5
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/shennawardana23/skillme/database-migrations)