database-migration
Skill1 starsChanged 7 months agoMITView on GitHub
Plan and execute database migrations: schema changes, data migrations, zero-downtime deployments, rollback strategies, and migration testing. Trigger with "database migration", "add a column", "change schema", "migrate data", "zero-downtime migration", "rollback plan", or when the user needs help with schema evolution, data transformation, or migration tooling.
21 other projects use a version of this.
Adopted by
Most recently taken up by
- The-AIOS/aiostheir own version, first seen Nov 3, 2026
- davidanthonyn/claude-skillstheir own version, first seen Oct 20, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- Samueladewole/claude-skillstheir own version, first seen Oct 13, 2026
- jeffstric/ZJTtheir own version, first seen Oct 9, 2026
- Rain-kl/OpenFlaretheir own version, first seen Oct 8, 2026
Used with
Projects with it also use mcp-builder.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillmcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Also in 3 projects that use this
Other versions21 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 21
- alekspetrov/navigator★ 355same name
- qf-studio/navigator★ 355same name
- Rain-kl/OpenFlare★ 298same name
- jeffstric/ZJT★ 240same name
- exelearning/exelearning★ 153same name
- The-AIOS/aios★ 105same name
- yusupsupriyadi/claude-code-mastering★ 17same name
- xfstudio/skills★ 9same name
- accolver/skill-maker★ 4same name
- ai4brands-design/claude-skills★ 2same name
11 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository164 other files it gives its agents.
- instrument-data-to-allotropeSkill
- literature-reviewSkill
- nextflow-developmentSkill
- scientific-problem-selectionSkill
- scvi-toolsSkill
- single-cell-rna-qcSkill
- discover-brandSkill
- enforce-voiceSkill
- generate-guidelinesSkill
- csat-reportSkill
- customer-escalationSkill
- customer-researchSkill
- draft-responseSkill
- kb-articleSkill
- sentiment-analysisSkill
- ticket-triageSkill
- analyzeSkill
- build-dashboardSkill
- create-vizSkill
- data-context-extractorSkill
- data-modelingSkill
- data-pipelineSkill
- etl-designSkill
- explore-dataSkill
- sql-queriesSkill
- statistical-analysisSkill
- validate-dataSkill
- write-querySkill
- accessibility-reviewSkill
- component-librarySkill
- design-critiqueSkill
- design-handoffSkill
- design-systemSkill
- frontend-designSkill
- research-synthesisSkill
- user-researchSkill
- ux-copySkill
- wireframingSkill
- Agent DevelopmentSkill
- CLAUDE.md ManagementSkill
- MCP Server BuilderSkill
- Plugin DevelopmentSkill
- Prompt EngineeringSkill
- Skill CreatorSkill
- curriculum-designSkill
- lesson-planningSkill
- quiz-generatorSkill
- study-guideSkill
- tutoringSkill
- api-designSkill
- architectureSkill
- ci-cd-pipelineSkill
- code-reviewSkill
- debugSkill
- dependency-auditSkill
- deploy-checklistSkill
- documentationSkill
- error-handlingSkill
- git-workflowSkill
- incident-responseSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. 0 are common, 11 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 16 edited versions we read keep these.
11
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 37
Current schema: Read existing migration files or schema definition.
- Very specific: line 42
Look for prisma/schema.prisma, knexfile.js, sequelize config, alembic.ini, db/migrate/ (Rails), Django migrations/, TypeORM entities, …
- Distinctive: line 43
Check for raw SQL migration directories.
- Distinctive: line 185
Before applying to production:
- Distinctive: line 188
Test the rollback: Run migrate down, verify the schema reverts cleanly.
- Distinctive: line 257
Action: Check the table size, design a safe migration with nullable column first, generate the migration file using the project's tool, …
- Very specific: line 270
Always write both up and down migrations.
- Distinctive: line 272
Never modify a migration that has already been applied to production.
- Distinctive: line 273
Use batched updates for data migrations on large tables.
- Distinctive: line 274
Add indexes concurrently (PostgreSQL) or with online DDL (MySQL) to avoid blocking writes.
- Distinctive: line 275
Test migrations with production-scale data before deploying.
- Distinctive: line 278
Keep migrations small and focused.
- Distinctive: line 279
Document the business reason for each migration in the migration file comments.
“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Migration
Plan and execute database schema changes and data migrations safely. Covers migration file generation, zero-downtime deployment strategies, rollback plans, data backfilling, and testing migrations against production-like data.
Workflow
Step 1: Understand the Change
Gather context about the migration:
- What is changing: New table, new column, column type change, index addition, data transformation.
- Why: Feature requirement, performance optimization, data model normalization.
- Current schema: Read existing migration files or schema definition. Check the ORM models/entities.
- Data volume: How many rows are in the affected tables? This determines the migration strategy.
- Downtime tolerance: Can the application go offline during migration, or must it be zero-downtime?
Detect the migration tool:
- Look for
prisma/schema.prisma,knexfile.js,sequelizeconfig,alembic.ini,db/migrate/(Rails), Djangomigrations/, TypeORM entities,drizzle.config.ts. - Check for raw SQL migration directories.
Step 2: Assess Risk
Classify the migration by risk level:
Low Risk (safe, backward compatible):
- Adding a new nullable column
- Adding a new table
- Adding an index (with
CONCURRENTLYon PostgreSQL) - Adding a new enum value
Medium Risk (requires coordination):
- Adding a NOT NULL column with a default value
- Renaming a column (requires application code change)
- Adding a unique constraint (may fail on existing data)
- Changing column type with compatible conversion
High Risk (potential downtime or data loss):
- Dropping a column or table
- Changing column type with incompatible conversion
- Large data backfill on tables with millions of rows
- Splitting or merging tables
Step 3: Design the Migration
Adding a column (safe pattern):
-- Migration: up
ALTER TABLE users ADD COLUMN phone VARCHAR(20) DEFAULT NULL;
-- Migration: down (rollback)
ALTER TABLE users DROP COLUMN phone;Adding a NOT NULL column (safe pattern):
-- Step 1: Add nullable column with default
ALTER TABLE orders ADD COLUMN status VARCHAR(20) DEFAULT 'pending';
-- Step 2: Backfill existing rows (in batches for large tables)
UPDATE orders SET status = 'completed' WHERE completed_at IS NOT NULL;
UPDATE orders SET status = 'pending' WHERE completed_at IS NULL;
-- Step 3: Add NOT NULL constraint (after backfill is verified)
ALTER TABLE orders ALTER COLUMN status SET NOT NULL;Renaming a column (zero-downtime pattern):
Phase 1 (migration): Add new column, copy data
Phase 2 (deploy): Application writes to both old and new columns
Phase 3 (migration): Backfill any remaining rows
Phase 4 (deploy): Application reads from new column only
Phase 5 (migration): Drop old column-- Phase 1
ALTER TABLE users ADD COLUMN full_name VARCHAR(255);
UPDATE users SET full_name = name;
-- Phase 5 (after application is updated)
ALTER TABLE users DROP COLUMN name;Adding an index (zero-downtime):
-- PostgreSQL: use CONCURRENTLY to avoid table lock
CREATE INDEX CONCURRENTLY idx_orders_user_id ON orders (user_id);
-- MySQL: use ALGORITHM=INPLACE for online DDL
ALTER TABLE orders ADD INDEX idx_user_id (user_id), ALGORITHM=INPLACE, LOCK=NONE;Large data migration (batched):
-- Do NOT run a single UPDATE on millions of rows
-- Instead, batch in chunks:
-- Pseudocode for batched migration:
-- loop:
-- UPDATE table SET new_col = transform(old_col)
-- WHERE id IN (SELECT id FROM table WHERE new_col IS NULL LIMIT 1000);
-- COMMIT;
-- SLEEP(0.1); -- reduce load on the database
-- IF affected_rows == 0: BREAKStep 4: Write the Migration File
Generate the migration using the project's tool:
Prisma:
npx prisma migrate dev --name add_user_phoneKnex:
npx knex migrate:make add_user_phoneexports.up = function(knex) {
return knex.schema.alterTable('users', (table) => {
table.string('phone', 20).nullable();
});
};
exports.down = function(knex) {
return knex.schema.alterTable('users', (table) => {
table.dropColumn('phone');
});
};Alembic (Python/SQLAlchemy):
alembic revision --autogenerate -m "add_user_phone"def upgrade():
op.add_column('users', sa.Column('phone', sa.String(20), nullable=True))
def downgrade():
op.drop_column('users', 'phone')Django:
python manage.py makemigrations --name add_user_phoneRails:
rails generate migration AddPhoneToUsers phone:stringStep 5: Test the Migration
Before applying to production:
- Run on a local database with realistic data volumes.
- Test the rollback: Run migrate down, verify the schema reverts cleanly.
- Test with production data (anonymized): If possible, restore a production backup to a staging database and run the migration there.
- Measure execution time: Time the migration on a dataset similar in size to production.
- Check for locks: Monitor for table locks during the migration, especially on large tables.
- Verify application compatibility: Deploy the application code against both the old and new schema to confirm backward compatibility during the transition.
Step 6: Deploy the Migration
Deployment checklist:
- Migration tested on staging with production-like data
- Rollback migration tested and verified
- Application code is compatible with both old and new schema
- Database backup taken before migration
- Monitoring alerts reviewed (disk space, CPU, lock wait times)
- Maintenance window scheduled (if needed for high-risk migrations)
- Rollback trigger criteria defined (what constitutes a failed migration)
Rollback strategy:
- For schema changes: Run the
downmigration. - For data migrations: Restore from the pre-migration backup.
- For large migrations: Keep the old column/table until the new version is verified, then clean up in a subsequent migration.
Output Format
## Database Migration Plan
### Change Description
<what is changing and why>
### Risk Assessment
**Risk Level**: Low / Medium / High
**Downtime Required**: Yes / No
**Estimated Duration**: <time for migration on production data>
**Affected Tables**: <list with row counts>
### Migration Steps
#### Step 1: <description>
```sql
<SQL or migration code>Rollback:
<rollback SQL>Pre-Migration Checklist
- Backup taken
- Tested on staging
- Rollback verified
- Application code deployed (if needed first)
Post-Migration Verification
- Schema matches expected state
- Application health checks passing
- Query performance verified
- Data integrity checks passing
Rollback Plan
Trigger: <when to rollback>
Procedure:
- <step 1>
- <step 2>
## Examples
**User**: "Add a status column to the orders table"
**Action**: Check the table size, design a safe migration with nullable column first, generate the migration file using the project's tool, include rollback, provide deployment instructions.
**User**: "Rename the 'name' column to 'full_name' in users table without downtime"
**Action**: Design a multi-phase migration (add new column, dual-write, backfill, switch reads, drop old column), generate migration files for each phase, provide application code changes needed.
**User**: "We need to split the address fields out of the users table into a separate addresses table"
**Action**: Design a data migration plan with batched data copy, foreign key setup, application code changes, and cleanup migration. Include rollback strategy.
**User**: "The migration is taking too long on production"
**Action**: Analyze the migration SQL, check for table locks, suggest batching strategies, recommend index-related optimizations, consider running during low-traffic periods.
## Best Practices
- Always write both `up` and `down` migrations. A migration without a rollback is a one-way door.
- Make migrations backward compatible when possible. The old application version should still work with the new schema during rolling deployments.
- Never modify a migration that has already been applied to production. Create a new migration to make corrections.
- Use batched updates for data migrations on large tables. A single UPDATE on 10 million rows will lock the table and potentially crash the database.
- Add indexes concurrently (PostgreSQL) or with online DDL (MySQL) to avoid blocking writes.
- Test migrations with production-scale data before deploying. A migration that runs in 2 seconds on 1,000 rows may take 2 hours on 10 million rows.
- Take a database backup before every production migration. Automate this as part of the deployment process.
- Monitor database metrics during migration: lock waits, CPU, disk I/O, replication lag.
- Keep migrations small and focused. One migration per logical change makes rollbacks surgical rather than catastrophic.
- Document the business reason for each migration in the migration file comments. Future developers need to understand why, not just what.Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

