Db migrate
π€ The ultimate curated collection of production-ready Claude Code skills with a framework to build your own.
npx -y skills add kasimmj/claude-skills-mega --skill db-migrateAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 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.
What its author says it does
Copied from the file, not written here
Generate safe, reversible SQL migrations with proper up/down statements, transactional wrappers, and rollback safety checks. Supports Postgres, MySQL, SQLite.
The file declares its own license as MIT. That is the authorβs claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
3.2 KB, as published. Nobody here has run it
DB Migrate Skill
You are generating a database migration. Migrations must be reversible, safe under concurrent writes, and idempotent where possible.
Step 1 β Detect the migration tool
Look for these markers (in order):
migrations/ordb/migrate/directory- Tool config files:
knexfile.*,alembic.ini,migrate.yaml,prisma/schema.prisma,supabase/migrations/ - ORM clues in
package.json,requirements.txt,go.mod
If you can't tell, ask before writing.
Step 2 β Compute the next filename
Standard formats:
YYYYMMDDHHmmss_<slug>.sql(Supabase, Knex)001_<slug>.sql(sequential)<n>_<slug>.{up,down}.sql(separate files)
Use git log and the existing migrations dir to determine the convention. Never break the existing pattern.
Step 3 β Write the migration
For each operation, follow these safety rules:
Adding a column
- β
ADD COLUMN ... NULL DEFAULT <value>β safe - β
ADD COLUMN ... NOT NULLwithout default β breaks on large tables - β Two-step: add nullable β backfill in batches β add NOT NULL constraint
Removing a column
- π¨ Two-deploy approach required:
- Deploy code that stops reading/writing the column
- Then drop it in a follow-up migration
- Document this in a comment block.
Renaming a column
- π¨ Three-step approach:
- Add new column, copy data
- Update code to use new column
- Drop old column
Adding an index
- β
CREATE INDEX CONCURRENTLYon Postgres for tables > 1M rows - β Regular
CREATE INDEXwill lock the table
Foreign keys
- Use
ON DELETEstrategy explicitly. Never default.
Step 4 β Provide rollback
For each up, write the inverse down. If the down would lose data, say so explicitly in a comment.
-- up
ALTER TABLE users ADD COLUMN email_verified BOOLEAN DEFAULT FALSE;
-- down
-- β οΈ This is destructive β deleted rows can't be recovered.
ALTER TABLE users DROP COLUMN email_verified;
Step 5 β Wrap in a transaction (where possible)
- Postgres/SQLite: wrap in
BEGIN; ... COMMIT; - MySQL: most DDL is implicit-commit; warn the user.
- Statements that cannot be in a transaction (e.g.,
CREATE INDEX CONCURRENTLY) go in their own migration file.
Step 6 β Hand off
Print:
- The file path created
- The exact command to apply (
npm run migrate,alembic upgrade head,supabase migration up) - The exact rollback command
When NOT to use
- Seeding test data (use a fixture skill instead)
- ORM-driven schema changes that are auto-generated (Prisma migrate, ActiveRecord)
- Stored procedure-only changes (use
stored-procskill if available)
Failure modes
- β οΈ Backfills against tables > 10M rows should be done outside the migration in a chunked job. Suggest this when relevant.
- β οΈ Always recommend running migrations on a staging copy first.