0
3

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.

ER図をGit管理する方法

Last updated at Posted at 2021-05-13

はじめに

PhpStormはPHPのコードを書くためのIDEですが、プラグインを入れることでUMLも書くことができます。
UMLを書けるということは言い換えるとER図を書くことができ、同時にファイルをGitでバージョン管理することもできます。
普段使い慣れているエディタでER図を書くことができるので作業効率はぐんとアップすること間違いなしです!
※PhpStorm以外にもVisualCodeなどでも類似のことが可能ですが内容は省略いたします

インストール

PhpStormでUMLをグラフィカルに表示するためには【graphviz】というツールが事前に必要です。
サイトからダウンロード、インストールしておきましょう。

PhpStormのプラグインのインストール

Untitled.png
プラグインの検索枠にumlと入力し、一覧に表示された上記プラグインをインストールします。
※プラグインの反映にはPhpStormの再起動が必要です

PlantUMLの機能について

PlantUMLをインストールするとPhpStormでファイルを新規作成(Ctrl+N)する際の選択一覧に「PlantUML」が追加されるようになります。
これを選択するとUMLを記述するためのファイルを新規作成することができます。
また、ウィンドウ右端にPlantUMLタブが追加され、編集結果をリアルタイムで確認することができるようになります。

使用例

image.png

ER図のサンプル

@startuml

'区分罫線を非表示
hide empty members

'マークと背景色の定義
!define master_data_db #E2EFDA-C6E0B4
!define user_db #FCE4D6-F8CBAD
!define MASTER_DATA AAFFAA
!define User FFAA00

'設定色を定義
skinparam class {
    BorderColor Black
    ArrowColor Black
}

package "ユーザー管理" as user {
    entity "accounts [アカウント]" as accounts <<U, User>> user_db {
        + id : bigInteger [ID]
        # user_id  :  bigInteger  [ユーザID]
    }

    entity "users [ユーザー]" as users <<U, User>> user_db {
        + id : bigInteger [ID]
        name : string [名前]
    }

    entity "prefectures [都道府県]" as prefectures <<M, MASTER_DATA>> master_data_db {
        + id : integer [ID]
        name : string [県名]
    }
}

'関係図を定義
users        ||-up-||     accounts

'テーブルメモ
note right of prefectures : メモです
@enduml

参考

0
3
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
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?