data-analysis
Automate Safe Database Migrations with create-migration
Learn how the create-migration skill helps AI agents generate safe, reversible database migrations with proper naming and review.
Where this fits
A developer is mid-feature and asks their AI agent to "add a migration for the new users.avatar_url column." Without guardrails, the agent might generate a migration with a raw DELETE, forget a rollback, or use an inconsistent filename. The create-migration skill turns this request into a disciplined workflow: clarify the change, name the file correctly, write UP and DOWN migrations, and review for safety. It fits directly into the schema-change loop, especially for teams that enforce backward compatibility and reversible migrations.
Why agents benefit
- Enforces naming conventions – The agent follows a timestamped
YYYYMMDDHHMMSS_descriptive_action.sqlformat, matching project standards without manual prompting. - Builds reversible migrations – It generates both UP and DOWN steps, then tests that DOWN reverts UP cleanly, reducing broken rollbacks.
- Applies safety rules automatically – No raw
DELETE, no non-parameterized SQL, and new columns get defaults; the agent self-reviews against these rules. - Handles failure recovery – If DOWN doesn't revert cleanly or unsafe patterns appear, the skill provides explicit recovery steps (fix, retest, document manual steps).
- Promotes backward compatibility – Clarifies whether the change is additive or breaking, and uses
CREATE INDEX CONCURRENTLYwhere supported.
Practical scenarios
Adding a column with a default
The user asks to add is_active to the accounts table. The agent clarifies the default value, writes an UP migration with ADD COLUMN ... DEFAULT true, and a DOWN migration that drops the column. It verifies the DOWN restores the previous schema exactly.
Creating an index on a foreign key
A query is slow due to a missing index on orders.user_id. The agent generates an UP migration with CREATE INDEX CONCURRENTLY (if supported) and a DOWN that drops the index. It also checks that the index name follows the project's naming pattern.
Soft-delete refactor
A user asks to remove a customers table. The agent recognizes a destructive change, prompts for a soft-delete approach instead, and writes a migration that adds a deleted_at column and filters queries accordingly—avoiding a raw DELETE entirely.
Add it to your agent workflow
Install the skill with:
npx skills add girijashankarj/cursor-handbook --skill create-migration
Then, in your agent prompt, simply say: "Create a migration to add a last_login_at timestamp to users." The skill will guide the agent through clarification, naming, UP/DOWN generation, and safety review. For a full reference, see the skill page on OpenAgentSkill.
Compare before adopting
Before adding this skill, compare it against:
- Quality signals – Does the skill's README include concrete failure recovery? (Yes, it has a table.) Does it enforce real safety rules?
- Maintenance freshness – Check the GitHub repo for recent commits and issue responses. A stale skill may miss newer database features.
- Alternatives – Look for other migration skills that might support your specific ORM or database (e.g., Alembic, Prisma). This one is SQL-agnostic but assumes raw SQL files.
- Workflow fit – Does it match your team's naming and review process? If you use a different migration tool, this skill may need adaptation.
Why it is worth tracking
With 30 stars and clear, actionable steps, this skill shows early community traction. Its focus on safety and reversibility addresses a common pain point in agent-generated code. Track it if you frequently ask agents to touch database schemas, and re-evaluate when you adopt a new database tool or migration framework—it may need updating to stay aligned with your workflow.
Featured Skill
create-migration
Skill by girijashankarj