bobmatnyc avatar

Database Migration

Shows you how to change database schemas in production without breaking things or taking downtime. Covers the expand-contract pattern (add new column, backfill data, make required, drop old column), safe ways to add indexes with CONCURRENTLY, and how to handle renaming columns or changing types across multiple deploys. Includes decision trees for picking migration strategies and troubleshooting guides for when migrations fail halfway through. Works with Alembic, Knex, Rails migrations, and other common tools. The multi-phase approach feels slow when you're used to just altering tables, but it's how you avoid 3am rollbacks.

skills.sh installs
427
GitHub stars
79
last updated
Aug 21, 2026

Install

$ npx -y skills add bobmatnyc/claude-mpm-skills --skill database-migration --agent claude-code

Installs into .claude/skills of the current project.

Files

Database Migration

Safe patterns for evolving database schemas in production.

Migration Principles

  1. Backward compatible - New code works with old schema
  2. Reversible - Can rollback if needed
  3. Tested - Verify on staging before production
  4. Incremental - Small changes, not big-bang
  5. Zero downtime - No service interruption

Safe Migration Pattern

Phase 1: Add New (Compatible)

-- Add new column (nullable initially)
ALTER TABLE users ADD COLUMN full_name VARCHAR(255) NULL;

-- Deploy new code that writes to both old and new
UPDATE users SET full_name = CONCAT(first_name, ' ', last_name);

Phase 2: Migrate Data

-- Backfill existing data
UPDATE users
SET full_name = CONCAT(first_name, ' ', last_name)
WHERE full_name IS NULL;

Phase 3: Make Required

-- Make column required
ALTER TABLE users ALTER COLUMN full_name SET NOT NULL;

Phase 4: Remove Old (After New Code Deployed)

-- Remove old columns
ALTER TABLE users DROP COLUMN first_name;
ALTER TABLE users DROP COLUMN last_name;

Common Migrations

Sponsors

Details

Repository
github.com/bobmatnyc/claude-mpm-skills
Categories
Backend & APIs, Debugging, Productivity & Planning, Databases
First seen
Jun 3, 2026

More from bobmatnyc/claude-mpm-skills

All 158
1sickn33 avatardatabase-adminsickn33/antigravity-awesome-skillsdatabase admin423skills.sh installs
2sickn33 avatarauth-implementation-patternssickn33/antigravity-awesome-skillsauth implementation patterns418skills.sh installs
3davila7 avataropenalex-databasedavila7/claude-code-templatesQuery and analyze scholarly literature using the OpenAlex database. This skill should be used when searching for academic papers, analyzing research trends, fin416skills.sh installs
4secondsky avatarapi-changelog-versioningsecondsky/claude-skillsCreates comprehensive API changelogs documenting breaking changes, deprecations, and migration strategies for API consumers. Use when managing API versions, com415skills.sh installs
5secondsky avatarapi-versioning-strategysecondsky/claude-skillsImplements API versioning using URL paths, headers, or query parameters with backward compatibility and deprecation strategies. Use when managing multiple API v410skills.sh installs
6patricio0312rev avatarapi-docs-generatorpatricio0312rev/skillsGenerates API documentation using OpenAPI/Swagger specifications with interactive documentation, code examples, and SDK generation. Use when users request "API 407skills.sh installs