2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

HeadlessCMSのstrapiでER図が自動出力できるプラグインを試してみた

Posted at

はじめに

Nuxtで作ってる個人サイトのバックエンドにstrapiを使用してるんですが、ER図が欲しくなったので自動出力してくれるプラグインを試してみました。

(以前書いたstrapiの環境構築記事はこちら)

目次

  1. 調査
  2. インスコ
  3. 実行結果
  4. 参考文献

調査

strapiを触ってるとGUIでぽちぽちDBが作れます。
ER図もここから生成できればいいなと思い、何かないか調べてみました。

strapi公式のissuesでER図の話がされてました。
このissues内の最新コメントにER図出力するstrapi-plugin-entity-relationship-chartというプラグインを作ったって報告してる人がいたので試してみることにしました。

strapiはオープンソースのHeadlessCMSなので、なんかやりたいことがあったときはみんな自分でプラグイン作ったりしてるみたいですね(すげえ)。

インスコ

プラグイン名:strapi-plugin-entity-relationship-chart

このプラグインを入れます。
https://www.npmjs.com/package/strapi-plugin-entity-relationship-chart


# npmでもyarnでもどちらでも可
$ yarn add strapi-plugin-entity-relationship-chart

# admin画面を再ビルドしてプラグインを適用(こうしないと反映されません)
$ yarn build

# 実行
$ yarn develop 

実行結果

ER図が出ました。
(吐き出したのはこれのER図)
スクリーンショット_2021-06-16_8_31_36.png

図が描画された範囲で線を繋ぎ変えたり、テーブルの位置を動かしたりなど編集ができるようになってます。
図をpngやjpgなどで保存・エクスポートする機能はありません。

ArticlesCommentsはhas_manyで繋がってるんですが、鳥の足が表示されてないですね。
表示を変えれるオプションはなさそうですが、必要十分な結果が出力されているので満足です。

GUI上のcontent-types-builderでテーブルを追加した際に、再ビルドすればEntity-Relationship-Chartにすぐ反映されるのは中々便利そうだなと思いました。

おしまい

参考文献

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?