Database migrations
Database migration patterns and ORM conventions. Auto-loaded when working with schema changes, migrations, models, or SQL files.From its SKILL.md
npx -y skills add littlelingo/context-engine --skill database-migrationsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
1.6 KB, as published. Nobody here has run it
Database Migrations
Safety Rules
- NEVER run destructive migrations without explicit user approval
- Always create a rollback plan before applying migrations
- Test migrations on a copy of production data when possible
- Migrations must be idempotent - safe to run multiple times
Migration Checklist
- Write migration with both
upanddown(rollback) - Test up migration on empty database
- Test down migration (verify rollback works)
- Test up migration on database with existing data
- Check for data loss - does the migration destroy existing data?
- Add appropriate indexes for new columns used in WHERE/JOIN
- Consider table locks on large tables - use concurrent index creation
Naming
- Timestamp prefix:
20260321_add_user_roles.sql - Descriptive: what the migration does, not the ticket number
- One logical change per migration file
Schema Design
- Always include
created_atandupdated_attimestamps - Use UUIDs or ULIDs for public-facing IDs, sequential integers for internal
- Add NOT NULL constraints by default, allow NULL only when semantically correct
- Foreign keys with appropriate ON DELETE behavior (CASCADE, SET NULL, RESTRICT)
Common Pitfalls
- Adding NOT NULL column without default to table with existing rows
- Dropping columns that are still referenced in application code
- Running migrations that lock large tables during peak traffic
- Forgetting to update ORM models after schema changes