db-migration

Generates MySQL migration SQL scripts by comparing ERD documents with JPA entities.

Updated Feb 26, 2026
One-click install
npx skills add https://github.com/VelkaressiaBlutkrone/spring-python-llm-exam-mng --skill db-migration-velkaressiablutkrone
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: db-migration
Source: https://github.com/VelkaressiaBlutkrone/spring-python-llm-exam-mng/tree/main/.claude/skills/db-migration
Command: npx skills add https://github.com/VelkaressiaBlutkrone/spring-python-llm-exam-mng --skill db-migration-velkaressiablutkrone

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Keeping database schemas synchronized between ERD documentation and JPA entities is error-prone, and hand-written migration SQL risks data loss or broken foreign keys. This Skill analyzes the differences and produces safe, transactional MySQL migration scripts with rollback plans. ## Core Features & Use Cases - Diff Analysis: Compares ERD documents (ERD.md, ERD_ALIGNMENT.md) against current JPA entity classes to build a structured change list covering table renames, column changes, and FK updates. - Safe SQL Templates: Provides templates for table/column renaming, foreign key changes, nullable column additions, and seed data updates, all wrapped in transactions with paired rollback scripts. - Entity & Doc Synchronization: Guides updating @Table, @Column, and @JoinColumn annotations plus ERD documentation after the migration runs. - Use Case: When renaming a table referenced by multiple foreign keys, the Skill orders child-table changes before parent-table changes and emits both the forward migration and rollback SQL. ## Quick Start Ask the assistant to generate a migration script by comparing doc/ERD.md with the current JPA entities, for example: create a migration script for the ERD alignment changes.

Frequently Asked Questions about db-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a database migration script from JPA entities?▼

Compare your ERD documentation against the current JPA entity classes to build a change list, then emit one ALTER statement per change wrapped in a transaction. This Skill automates that diff analysis and produces the SQL with rollback statements.

How to rename a MySQL table without losing data?▼

Use ALTER TABLE old_name RENAME TO new_name instead of DROP plus CREATE, which preserves all existing rows. For columns, use ALTER TABLE ... CHANGE COLUMN rather than dropping and re-adding the column.

Should I use ddl-auto update or validate in production with Hibernate?▼

Use ddl-auto: validate in production so Hibernate never modifies the schema automatically; all changes go through reviewed migration scripts. The update setting is acceptable only in development databases.

How do I write a rollback script for a database migration?▼

Write the inverse of each forward operation in reverse order, wrapped in its own transaction and clearly labeled as a rollback section. Every migration produced by this Skill includes a paired rollback SQL block.

What order should foreign key table changes run in a migration?▼

Modify child tables before their parent tables so foreign key constraints remain satisfiable throughout the migration. The Skill performs a dependency check in Step 2 to determine this ordering before generating SQL.