Task: Code-generate ER diagram from SQL
This page documents a task in the Codegen infrastructure story. It captures the goal, current status, acceptance, and any notes or results.
Goal
Generate the PlantUML ER diagram directly from the SQL schema so it can't drift out of date.
Status
| Field | Value |
|---|---|
| State | DONE |
| Parent story | Codegen infrastructure |
| Now | Completed 2026-01-24. |
| Waiting on | None. |
| Next | None. |
| Last touched | 2026-01-24 |
Acceptance
- Python SQL parser (
plantuml_er_parse_sql.py) extracts tables, columns, PKs, unique indexes, FKs. - Tables auto-classified as
temporal,junction, orartefactand stereotyped. - Convention validation: naming, temporal-table shape, drop-script completeness, file organisation (strict-mode option).
- Mustache template (
plantuml_er.mustache) renders the diagram. - Shell orchestration:
plantuml_er_generate.sh+validate_schema.sh. - 22 existing SQL tables annotated with descriptions for diagram context.
Plan
Captured during execution; cleared into the parent story on close.
Notes
The convention-validation engine fell out of the parser for free; cheap insurance against schema drift.
Result
ER diagram is now a derived artefact, not a manually-edited one.