Add database migration generator and Mermaid ER diagram generator - #8
Draft
hatcheric950 wants to merge 1 commit into
Draft
Add database migration generator and Mermaid ER diagram generator#8hatcheric950 wants to merge 1 commit into
hatcheric950 wants to merge 1 commit into
Conversation
Two Python CLI tools for database developer productivity: - `db_tools/migration_generator.py`: diffs two JPA entity Java files and emits Flyway-compatible ALTER TABLE DDL (add/drop/rename/modify columns, unique constraint changes). Handles fully-qualified type names and both multi-line and same-line annotation styles. - `db_tools/er_diagram_generator.py`: parses SQL CREATE TABLE statements (MySQL/PostgreSQL/SQLite syntax, backtick/quote-quoted identifiers, table-level PK/FK/UNIQUE constraints) and produces a Mermaid erDiagram block. - `db_tools_cli.py`: argparse CLI with `migrate` and `er` sub-commands. - `examples/`: User entity v1/v2 pair and a 4-table e-commerce schema. - `tests/`: 58 unit tests covering all public functions (100% pass). https://claude.ai/code/session_012vCaNNL7Z6pJEBbjS8d8nQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
db_tools/migration_generator.py): diffs two JPA entity Java source files and emitsALTER TABLEDDL compatible with Flyway versioned migrations. Detects added/dropped columns, renames, type/nullability changes, and unique constraint changes. Handles fully-qualified type names (java.math.BigDecimal) and both multi-line and same-line annotation styles.db_tools/er_diagram_generator.py): parses SQLCREATE TABLEstatements (MySQL/PostgreSQL/SQLite, backtick/quote/bracket-quoted identifiers, table-level PK/FK/UNIQUE constraints) and produces aerDiagramMermaid block withPK/FK/UKmarkers and relationship lines.db_tools_cli.py):migrateandersub-commands with--outputflag support.Userentity v1→v2 diff pair and a 4-table e-commerce schema (users,orders,order_items,products).Test plan
python -m pytest tests/ -v— all 58 tests greenpython db_tools_cli.py migrate --old examples/entities/User_v1.java --new examples/entities/User_v2.java— produces correctALTER TABLE usersDDLpython db_tools_cli.py er --sql examples/schema.sql— produces valid 4-table MermaiderDiagramwith FK relationshipspython db_tools_cli.py er --sql examples/schema.sql --output diagram.md— writes fenced Mermaid block to filehttps://claude.ai/code/session_012vCaNNL7Z6pJEBbjS8d8nQ
Generated by Claude Code