database-migrations
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
Skill by matthewhand
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/matthewhand-database-migrations
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/database-migrations
What's inside
- Skill name
database-migrations- Description
- Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs (Prisma, Drizzle, Kysely, Django, TypeORM, golang-migrate).
- License
- MIT
- Metadata
- origin: ECC
- Instructions
- 425 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# 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
1. **Every change is a migration** — never alter production databases manually
2. **Migrations are forward-only in production** — rollbacks use new forward migrations
3. **Schema and data migrations are separate** — never mix DDL and DML in one migration
4. **Test migrations against production-sized data** — a migration that works on 100 rows may lock on 10M
5. **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
```sql
-- GOOD: Nullable column, no lock
ALTER TABLE users ADD COLUMN avatar_url TEXT;
-- GOOD: Column with default (Postgres 11+ is instant, no rewrite)
ALTER TABLE users ADD COLUMN is_active BOOLEAN NOT NULL DEFAULT true;
-- BAD: NOT NULL without default on existing table (requires full rewrite)
ALTER TABLE users ADD COLUMN role TEXT NOT NULL;
-- This locks the table and rewrites every row
```
### Adding an Index Without Downtime
```sql
-- BAD: Blocks writes on large tables
CREATE INDEX idx_users_email ON users (email);
-- GOOD: Non-blocking, allows concurrent writes
CREATE INDEX CONCURRENTLY idx_users_email ON users (email);
-- Note: CONCURRENTLY cannot run inside a transaction block
-- Most migration tools need special handling for this
```
### Renaming a Column (Zero-Downtime)
Never rename directly in production. Use the expand-contract pattern:
```sql
-- Step 1: Add new column (migration 001)
ALTER TABLE users ADD COLUMN display_name TEXT;
-- Step 2: Backfill data (migration 002, data migration)
UPDATE users SET display_name = username WHERE display_name IS NULL;
-- Step 3: Update application code to read/write both columns
-- Deploy application changes
-- Step 4: Stop writing to old column, drop it (migration 003)
ALTER TABLE users DROP COLUMN username;
```
### Removing a Column Safely
```sql
-- Step 1: Remove all application references to the column
-- Step 2: Deploy application without the column reference
-- Step 3: Drop column in next migration
ALTER TABLE orders DROP COLUMN legacy_status;
-- For Django: use SeparateDatabaseAndState to remove from model
-- without generating DROP COLUMN (then drop in next migration)
```
### Large Data Migrations
```sql
-- BAD: Updates all rows in one transaction (locks table)
UPDATE users SET normalized_email = LOWER(email);
-- GOOD: Batch update with progress
DO $$
DECLARE
batch_size INT := 10000;
rows_updated INT;
BEGIN
LOOP
UPDATE users
SET normalized_email = LOWER(email)
WHERE id IN (
SELECT id FROM users
WHERE normalized_email IS NULL
LIMIT batch_size
FOR UPDATE SKIP LOCKED
);
GET DIAGNOSTICS rows_updated = ROW_COUNT;
RAISE NOTICE 'Updated % rows', rows_updated;
EXIT WHEN rows_updated = 0;
COMMIT;
END LOOP;
END $$;
```From matthewhand/operating-swarm, MIT.
More from matthewhand/operating-swarm
- 0.644score
orca-cli
matthewhand
Drive a running Orca ADE (stablyai/orca) through the documented orca JSON CLI for worktrees and agent terminals.
SkillAFreshness: A★ 20Claude Code +9 - 0.644score
support-session-ownership
matthewhand
Teaches Support the first-run open-swarm journey and when Operating Swarm owns a thread versus CLI or remote sessions.
SkillAFreshness: A★ 20Claude Code +9 - 0.641score
error-handling
matthewhand
Patterns for robust error handling across TypeScript, Python, and Go.
SkillAFreshness: A★ 20Claude Code +9 - 0.629score
teamai-baseline
matthewhand
Shared TeamAI rules baseline (coding style, review, testing, git, security, performance) for Operating Swarm seats.
SkillAFreshness: A★ 20Claude Code +9 - 0.619score
domain-modeling
matthewhand
Build and sharpen a project's domain model.
SkillAFreshness: A★ 20Claude Code +9 - 0.607score
backend-patterns
matthewhand
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
SkillAFreshness: A★ 20Claude Code +9 - 0.604score
self-update-pr
matthewhand
Open a real GitHub pull request on matthewhand/open-swarm from an in-app coding CLI.
SkillBFreshness: B★ 20Claude Code +9 - 0.604score
ddg-search
matthewhand
Perform web searches using DuckDuckGo (free, no API key) via the bundled search.py script.
SkillBFreshness: B★ 20Claude Code +9 - 0.554score
writing-changelog
matthewhand
Writes a Keep a Changelog entry from a description of changes or a git log.
SkillCFreshness: C★ 20Claude Code +9 - 0.554score
reviewing-code
matthewhand
Reviews a diff or file for bugs, security issues, and missing tests, returning prioritized findings.
SkillCFreshness: C★ 20Claude Code +9 - 0.554score
conventional-commit
matthewhand
Writes a single Conventional Commits message from a description of changes or a git diff.
SkillCFreshness: C★ 20Claude Code +9 - 0.549score
counting-lines
matthewhand
Counts the non-blank lines in a file using the bundled count.py script.
SkillCFreshness: C★ 20Claude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 20
- Forks
- 6
- Open issues
- 1
- Last commit (this folder)
- Sep 30, 2026 (27 days ago)
- Last release
- Jun 19, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/matthewhand/operating-swarm
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.334score
database-migrations
lengoctuong2005
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
SkillAFreshness: AClaude Code +9 - 0.313score
database-migrations
airclear
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
SkillBFreshness: BClaude Code +9 - 0.313score
database-migrations
terryzwt
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
SkillBFreshness: BClaude Code +9 - 0.313score
database-migrations
worldsoon
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
SkillBFreshness: BClaude Code +9 - 0.290score
database-migrations
junjiezhou1122
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
SkillBFreshness: BClaude Code +9 - 0.244score
database-migrations
riverosmejia
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
SkillDFreshness: DClaude Code +9 - 0.241score
database-migrations
diegosfb
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
SkillDFreshness: DClaude Code +9
More from matthewhand
- 0.644score
orca-cli
matthewhand
Drive a running Orca ADE (stablyai/orca) through the documented orca JSON CLI for worktrees and agent terminals.
SkillAFreshness: A★ 20Claude Code +9 - 0.644score
support-session-ownership
matthewhand
Teaches Support the first-run open-swarm journey and when Operating Swarm owns a thread versus CLI or remote sessions.
SkillAFreshness: A★ 20Claude Code +9 - 0.641score
error-handling
matthewhand
Patterns for robust error handling across TypeScript, Python, and Go.
SkillAFreshness: A★ 20Claude Code +9 - 0.629score
teamai-baseline
matthewhand
Shared TeamAI rules baseline (coding style, review, testing, git, security, performance) for Operating Swarm seats.
SkillAFreshness: A★ 20Claude Code +9 - 0.619score
domain-modeling
matthewhand
Build and sharpen a project's domain model.
SkillAFreshness: A★ 20Claude Code +9 - 0.607score
backend-patterns
matthewhand
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
SkillAFreshness: A★ 20Claude Code +9
Cite this page
database-migrations skill. Agent Mart. https://agentmart.dev/skills/matthewhand-database-migrations (last updated 2026-10-24)