Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
girijashankarj avatar

Migration

  • 1 installs
  • 27 repo stars
  • Updated April 25, 2026
  • girijashankarj/cursor-handbook

Safe workflow to create and apply database schema changes with up/down migrations, safety checks, batched data migration, and testing.

About

Guides creating and applying database schema changes safely with reversible migrations and safety checks. A developer uses it when modifying the database schema.

  • Writes UP and DOWN migrations with concurrent indexes
  • Batches idempotent data migrations and tests rollback

Migration by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #770 of 911 Databases skills by installs in the Skillselion catalog
  • Data as of Jul 22, 2026 (Skillselion catalog sync)
npx skills add https://github.com/girijashankarj/cursor-handbook --skill migration

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars27
Last updatedApril 25, 2026
Repositorygirijashankarj/cursor-handbook

What it does

Safe workflow to create and apply database schema changes with up/down migrations, safety checks, batched data migration, and testing.

Files

SKILL.mdMarkdownGitHub ↗

Skill: Create Database Migration

Trigger

When the user needs to modify the database schema.

Steps

Step 1: Plan the Change

  • [ ] Define what's changing and why
  • [ ] Check for backward compatibility
  • [ ] Identify affected queries and code
  • [ ] Determine if data migration is needed

Step 2: Create Migration File

  • [ ] Name: YYYYMMDDHHMMSS_descriptive_name.sql
  • [ ] Write UP migration (apply change)
  • [ ] Write DOWN migration (rollback)
  • [ ] Include required columns: {{CONFIG.database.timestampFields.created}}, {{CONFIG.database.timestampFields.updated}}, {{CONFIG.database.softDeleteField}}

Step 3: Safety Checks

  • [ ] No DELETE FROM statements (soft delete only)
  • [ ] New columns have defaults or are nullable
  • [ ] Indexes created with CONCURRENTLY for large tables
  • [ ] No column renames (add new → migrate → drop old)
  • [ ] Foreign keys have appropriate cascade rules

Step 4: Data Migration

If needed:

  • [ ] Write data migration script
  • [ ] Use batch processing (1000-5000 rows per batch)
  • [ ] Make it idempotent (safe to re-run)
  • [ ] Include progress logging

Step 5: Test Migration

  • [ ] Apply to development database
  • [ ] Verify data integrity
  • [ ] Test rollback
  • [ ] Test with production-like data volume
  • [ ] Verify affected queries still work

Step 6: Update Code

  • [ ] Update models/types to match new schema
  • [ ] Update affected queries
  • [ ] Run type check: {{CONFIG.testing.typeCheckCommand}}
  • [ ] Run affected tests

If a step fails

StepFailureRecovery
Step 2Syntax error in migrationFix SQL; re-run
Step 4Data migration fails mid-runScript should be idempotent; fix and re-run; if partial data, document manual cleanup
Step 5Test migration failsRun DOWN migration to revert; fix UP migration; retest
Step 5Rollback test failsFix DOWN migration; ensure DOWN fully reverts UP before retrying

Never apply migrations to production without testing UP and DOWN in a non-prod environment first.

Completion

Migration created, tested, and code updated. Ready for review.

Related skills

Databasesdatabases

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.