📚
SchemaSpyのスキーマに任意のコメントを追加する
SchemaSpy公式ドキュメントの確認
公式ドキュメントに記載があるので記事化するほどでもありませんが、xmlを定義することで可能になります。
SchemaSpyによるDB仕様書の自動生成と、加えてテーブルやカラムごとの特性を任意にコメント化することで、よりチームメンバー間でDB仕様の認識共有が捗る取り組みが可能です。
既に、DB側でコメントが定義されている場合は不要です。あとからALTER文等で追加していくのも微妙だと判断した場合は有用な選択です。
サンプル
(公式ドキュメントより)
<schemaMeta xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schemaspy.org/xsd/6/schemameta.xsd" >
<comments>Database comment</comments>
<tables>
<table name="ACCOUNT" comments="Table comment">
<column name="accountId" comments="Column comment"/>
</table>
</tables>
</schemaMeta>
実行時
-meta
オプションによりxmlのパスを指定します。
$ java -jar /schemaspy/schemaspy.jar -db $DB_NAME -t mysql -host $DB_HOST -port $DB_PORT -s $DB_NAME -u $DB_USER -p $DB_PASS -dp /schemaspy/drivers/ -o /schemaspy/outputs -vizjs -meta schemaspy.xml
対象の箇所
公式サンプル( https://schemaspy.org/samples/epivirusurf/ )より抜粋です。
以下の箇所が反映されます。
Discussion