rails-mermaid_erd
rails-mermaid_erd copied to clipboard
Add table comments to SCHEMA_DATA.Models
Motivation / Background
ActiveRecord allows comments on tables as well as columns.
cf. https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-table_comment
However, rails-mermaid_erd
currently does not support table comments.
I want comments on tables along with ER diagrams in the following cases.
- Discussion of model design
- Explanation to non-engineers
- Explanation to new team members during on-boarding
Detail
We can now output table comments to SCHEMA_DATA.
We can get a table comment by using ::ActiveRecord::Base.connection.table_comment
.
cf. https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-table_comment
It was difficult to output them as ER diagram, so I implemented that they are output as mermaid code, it's similar to table names.