database-migrations
Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs…
Skill by Fmarzochi
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/fmarzochi-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: not checked yet.
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, Django, TypeORM, golang-migrate). Use when planning or implementing database schema changes.
- License
- Apache-2.0
- Metadata
- origin: EGC
- Instructions
- 339 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 Fmarzochi/EGC, Apache-2.0.
More from Fmarzochi/EGC
- 0.668score
dmux-workflows
Fmarzochi
Multi-agent orchestration using dmux (tmux pane manager for AI agents).
SkillAFreshness: A★ 67Claude Code +9 - 0.668score
product-capability
Fmarzochi
Translate PRD intent, roadmap asks, or product discussions into an implementation-ready capability plan that exposes constraints, invariants, interfaces, and…
SkillAFreshness: A★ 67Claude Code +9 - 0.662score
egc
Fmarzochi
Development conventions and patterns for EGC - Extended Global Context.
SkillAFreshness: A★ 67Claude Code +9 - 0.662score
eval-harness
Fmarzochi
Formal evaluation framework for AI coding sessions implementing eval-driven development (EDD) principles
SkillAFreshness: A★ 67Claude Code +9 - 0.659score
verification-loop
Fmarzochi
A comprehensive verification system for AI coding sessions.
SkillAFreshness: A★ 67Claude Code +9 - 0.628score
agent-sort
Fmarzochi
Build an evidence-backed EGC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using…
SkillBFreshness: B★ 67Claude Code +9 - 0.603score
article-writing
Fmarzochi
Write articles, guides, blog posts, tutorials, newsletter issues, and other long-form content in a distinctive voice derived from supplied examples or brand…
SkillBFreshness: B★ 67Claude Code +9 - 0.591score
backend-patterns
Fmarzochi
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
SkillBFreshness: B★ 67Claude Code +9 - 0.343score
mcp-server-patterns
Fmarzochi
No description from the publisher yet.
SkillBFreshness: B★ 67Claude Code +9 - 0.343score
nextjs-turbopack
Fmarzochi
No description from the publisher yet.
SkillBFreshness: B★ 67Claude Code +9
Signals
- Stars
- 67
- Forks
- 49
- Open issues
- 0
- Last commit (this folder)
- Jun 13, 2026 (4 months ago)
- Last release
- Sep 16, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/Fmarzochi/EGC
- Website
- fmarzochi.github.io/EGCSite/
- 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.
More from Fmarzochi
- 0.668score
dmux-workflows
Fmarzochi
Multi-agent orchestration using dmux (tmux pane manager for AI agents).
SkillAFreshness: A★ 67Claude Code +9 - 0.668score
product-capability
Fmarzochi
Translate PRD intent, roadmap asks, or product discussions into an implementation-ready capability plan that exposes constraints, invariants, interfaces, and…
SkillAFreshness: A★ 67Claude Code +9 - 0.662score
egc
Fmarzochi
Development conventions and patterns for EGC - Extended Global Context.
SkillAFreshness: A★ 67Claude Code +9 - 0.662score
eval-harness
Fmarzochi
Formal evaluation framework for AI coding sessions implementing eval-driven development (EDD) principles
SkillAFreshness: A★ 67Claude Code +9 - 0.659score
verification-loop
Fmarzochi
A comprehensive verification system for AI coding sessions.
SkillAFreshness: A★ 67Claude Code +9 - 0.628score
agent-sort
Fmarzochi
Build an evidence-backed EGC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using…
SkillBFreshness: B★ 67Claude Code +9
Cite this page
database-migrations skill. Agent Mart. https://agentmart.dev/skills/fmarzochi-database-migrations (last updated 2026-10-24)