• Stars
    star
    161
  • Rank 233,470 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ERD exporter with PlantUML and mermaid format

PlantERD

ERD exporter with PlantUML and mermaid format

Build Status Build Status Coverage Status Maintainability Go Report Card

Example (PlantUML)

$ ./plant_erd sqlite3 --database /path/to/test_db.sqlite3

entity articles {
  * id : integer
  --
  * user_id : integer
  --
  index_user_id_on_articles (user_id)
}

entity users {
  * id : integer
  --
  name : text
}

articles }-- users

example-plantuml

Example (mermaid)

$ ./plant_erd sqlite3 --database /path/to/test_db.sqlite3 --format=mermaid --show-comment

erDiagram

articles {
  INTEGER id PK
  INTEGER user_id FK
}

users {
  INTEGER id PK
  TEXT name
}

users ||--o{ articles : owns
erDiagram

articles {
  INTEGER id PK
  INTEGER user_id FK
}

users {
  INTEGER id PK
  TEXT name
}

users ||--o{ articles : owns

Features

  • Output ERD from real database
  • Output ERD to stdout or file
  • Output only tables within a certain distance adjacent to each other with foreign keys from a specific table

Supported databases

  • SQLite3
  • MySQL: 5.6, 5.7, 8
  • PostgreSQL: 9, 10, 11, 12, 13, 14, 15
  • Oracle

Supported output formats

Setup

Download latest binary from https://github.com/sue445/plant_erd/releases and chmod 755

  • plant_erd : for SQLite3, MySQL and PostgreSQL
  • plant_erd-oracle : for Oracle

Setup for plant_erd-oracle

plant_erd-oracle requires Basic Package or Basic Light Package in Oracle Instant Client

Example (Linux)

mkdir -p /opt/oracle
wget --quiet --tries=0 https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basiclite-linux.x64-19.3.0.0.0dbru.zip
unzip -q instantclient-basiclite-linux.x64-19.3.0.0.0dbru.zip -d /opt/oracle
export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_3

# for Ubuntu
apt-get update
apt-get install -y libaio1

Example (Mac)

See https://github.com/kubo/ruby-oci8/blob/master/docs/install-on-osx.md and install instantclient-basic or instantclient-basiclite

Example (Windows)

  1. Go to https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
  2. Download instantclient-basic-windows.x64-19.5.0.0.0dbru.zip or instantclient-basiclite-windows.x64-19.5.0.0.0dbru.zip
  3. Extract zip
  4. Move plant_erd-oracle to same directory as oci.dll

Usage

SQLite3

$ ./plant_erd sqlite3 --help
NAME:
   plant_erd sqlite3 - Generate ERD from sqlite3

USAGE:
   plant_erd sqlite3 [command options] [arguments...]

OPTIONS:
   -d DISTANCE, --distance DISTANCE  Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
   --database DATABASE               SQLite3 DATABASE file
   -f FILE, --file FILE              FILE for output (default: stdout)
   --format value                    Output format (plant_uml, mermaid. default:plant_uml)
   -i, --skip-index                  Whether don't print index to ERD. This option is used only --format=plant_uml
   -s value, --skip-table value      Skip generating table by using regex patterns
   --show-comment                    Show column comment. This option is used only --format=mermaid
   -t TABLE, --table TABLE           Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE

MySQL

$ ./plant_erd mysql --help
NAME:
   plant_erd mysql - Generate ERD from mysql

USAGE:
   plant_erd mysql [command options] [arguments...]

OPTIONS:
   --collation COLLATION             MySQL COLLATION (default: "utf8_general_ci")
   -d DISTANCE, --distance DISTANCE  Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
   --database DATABASE               MySQL DATABASE name
   -f FILE, --file FILE              FILE for output (default: stdout)
   --format value                    Output format (plant_uml, mermaid. default:plant_uml)
   --host HOST                       MySQL HOST (default: "localhost")
   -i, --skip-index                  Whether don't print index to ERD. This option is used only --format=plant_uml
   --password PASSWORD               MySQL PASSWORD [$MYSQL_PASSWORD]
   --port PORT                       MySQL PORT (default: 3306)
   -s value, --skip-table value      Skip generating table by using regex patterns
   --show-comment                    Show column comment. This option is used only --format=mermaid
   -t TABLE, --table TABLE           Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE
   --user USER                       MySQL USER (default: "root")

PostgreSQL

$ ./plant_erd postgresql --help
NAME:
   plant_erd postgresql - Generate ERD from PostgreSQL

USAGE:
   plant_erd postgresql [command options] [arguments...]

OPTIONS:
   -d DISTANCE, --distance DISTANCE  Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
   --database DATABASE               PostgreSQL DATABASE name
   -f FILE, --file FILE              FILE for output (default: stdout)
   --format value                    Output format (plant_uml, mermaid. default:plant_uml)
   --host HOST                       PostgreSQL HOST (default: "localhost")
   -i, --skip-index                  Whether don't print index to ERD. This option is used only --format=plant_uml
   --password PASSWORD               PostgreSQL PASSWORD [$POSTGRES_PASSWORD]
   --port PORT                       PostgreSQL PORT (default: 5432)
   -s value, --skip-table value      Skip generating table by using regex patterns
   --show-comment                    Show column comment. This option is used only --format=mermaid
   --sslmode SSLMODE                 PostgreSQL SSLMODE. c.f. https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS (default: "disable")
   -t TABLE, --table TABLE           Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE
   --user USER                       PostgreSQL USER

Oracle

$ ./plant_erd-oracle --help
NAME:
   plant_erd-oracle - ERD exporter with PlantUML and Mermaid format (for oracle)

USAGE:
   plant_erd-oracle [global options] command [command options] [arguments...]

VERSION:
   vX.X.X (build. xxxxxxx)

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   -f FILE, --file FILE              FILE for output (default: stdout)
   -t TABLE, --table TABLE           Output only tables within a certain distance adjacent to each other with foreign keys from a specific TABLE
   -d DISTANCE, --distance DISTANCE  Output only tables within a certain DISTANCE adjacent to each other with foreign keys from a specific table (default: 0)
   -i, --skip-index                  Whether don't print index to ERD. This option is used only --format=plant_uml
   -s value, --skip-table value      Skip generating table by using regex patterns
   --format value                    Output format (plant_uml, mermaid. default:plant_uml)
   --show-comment                    Show column comment. This option is used only --format=mermaid
   --user USER                       Oracle USER
   --password PASSWORD               Oracle PASSWORD [$ORACLE_PASSWORD]
   --host HOST                       Oracle HOST (default: "localhost")
   --port PORT                       Oracle PORT (default: 1521)
   --service SERVICE                 Oracle SERVICE name
   --help, -h                        show help
   --version, -v                     print the version

About --table and --distance

When --table and --distance are passed, output only tables within a certain distance adjacent to each other with foreign keys from a specific table.

Example 1: Output all tables

$ ./plant_erd sqlite3

example all

Example 2: Output only tables within a distance of 1 from the articles

$ ./plant_erd sqlite3 --table articles --distance 1

example distance 1 from articles

Testing

with all databases

Run test in container

docker-compose up --build --abort-on-container-exit

with only SQLite3

Run test on local

make test

License

The program is available as open source under the terms of the MIT License.

But plant_erd-oracle contains Oracle Instant Client. Oracle Instant Client is under OTN License.

More Repositories

1

jenkins-backup-script

archive jenkins setting and plugins
Ruby
436
star
2

chrome-gitlab-notifier

Notify Gitlab Project events (Commit, Issue, MergeRequest and Milestone)
JavaScript
148
star
3

rubicure

All about Japanese battle heroine "Pretty Cure (Precure)"
Ruby
135
star
4

gitpeach

waffle.io clone for Gitlab
Ruby
79
star
5

index_shotgun

duplicate index checker 🔥 🔫 👮
Ruby
34
star
6

rubocop-isucon

RuboCop plugin for ruby reference implementation of ISUCON
Ruby
29
star
7

ccc_privacy_crawler

Tカードの 個人情報提供の停止 対象企業一覧 の新着を通知するためのTwitterボットです
Ruby
26
star
8

pixela

Pixela API client for Ruby
Ruby
24
star
9

regional-rb-calendar

地域.rbの開催情報を集めたカレンダーです
Ruby
23
star
10

google_holiday_calendar

Get holidays via Google Calendar.
Ruby
21
star
11

gitpanda

GitLab URL expander for Slack
Go
20
star
12

heart_seed

seed util (convert excel to yaml and insert yaml to db)
Ruby
19
star
13

today_anime

これから放映されるアニメをポストするSlackボット
Ruby
19
star
14

zatsu_monitor

simple url monitoring tool
Go
17
star
15

circleci-ruby-orbs

CircleCI orb for ruby
Ruby
17
star
16

activerecord-simple_index_name

Shorten index name
Ruby
15
star
17

itamae-plugin-resource-encrypted_remote_file

encrypt secret data (e.g. id_rsa), and forward decrypted file to remote.
Ruby
14
star
18

dotfiles

自分用の設定ファイルとか
Shell
12
star
19

rubocop-itamae

Code style checking for itamae recipes
Ruby
12
star
20

twittodon

Search specific tweet and post toot to mastodon
Ruby
11
star
21

rspec-temp_dir

create automatically temporary directory at each examples
Ruby
11
star
22

git-base-study

ドリコム社内で行った「Git基礎勉強会」の資料です
11
star
23

gitlab_mr_release

Release MergeRequest generator for GitLab
Ruby
11
star
24

emoy_webhook

emoy webhook (Emoji notify webhook) notify when new emoji is add
Ruby
10
star
25

activerecord-compatible_legacy_migration

Compatible migration file between Rails 4.2 and 5+
Ruby
10
star
26

go-mod-tidy-pr

Run `go mod tidy` and create PullRequest on GitHub Actions
Shell
9
star
27

faker-precure

Test data generator using precure
Ruby
8
star
28

capistrano-itamae

Run itamae in capistrano task
Ruby
7
star
29

dockerhub-slack-webhook

Docker Hub webhook for slack notification after build
Ruby
7
star
30

gitlab-ci-example

Shell
7
star
31

dockerfile-heroku-cli

Dockerfile for heroku deployment
Dockerfile
6
star
32

rubocop_auto_corrector

Run `rubocop --auto-correct && git commit` with each cop.
Ruby
6
star
33

rubygems_check_replacement_vulnerability

[NO LONGER MAINTAINED] Check your gems whether affected by "RubyGems.org gem replacement vulnerability and mitigation"
Ruby
6
star
34

goprecure

[NO LONGER MAINTAINED] goprecure is golang implementation of "Go! Princess PreCure"
Go
6
star
35

primap

ワッチャプリマジ!、プリパラ オールアイドルの遊べるお店を地図で表示するサイト
Go
6
star
36

paraduct

[NO LONGER MAINTAINED] Paraduct (parallel + parameterize + product) is matrix test runner
Ruby
6
star
37

fluent-plugin-chatwork

fluentd output plugin for post to chatwork
Ruby
6
star
38

date_discreter

Check discrete of months, days and hours
Ruby
6
star
39

app-stat-api

Apple System Status UnOfficial API
Ruby
5
star
40

terraform-aws-template

Terraform template for AWS
HCL
5
star
41

compact_blank

[DEPRECATED] Adds compact_blank and compact_blank! to Array and Hash
Ruby
5
star
42

dio_tests

Do you remember how many tests you have written ?(お前は今まで書いたテストの個数を覚えているのか?)
Ruby
5
star
43

feed_squeezer

feed_squeezer returns a new feed squeezed by any keyword in feed
Go
5
star
44

idle-recruit-generator

アイドル募集ジェネレータ
HTML
4
star
45

dockerfile-awscli-all

Dockerfile with all awscli installed
Dockerfile
4
star
46

sebastian-badge

Hosting embed Jenkins plugin badges
Ruby
4
star
47

faraday-mashify

Faraday middleware for wrapping responses into Hashie::Mash
Ruby
4
star
48

tweet_pixels

Tweet pixels
Ruby
4
star
49

apple_system_status

Apple System Status scraping library
Ruby
4
star
50

cure-mastodon-bots

cure bot on https://precure.ml
Ruby
4
star
51

s3tiger

"S3 Tiger" is test utility for Slim3
Java
4
star
52

tddbc_tokyo_20130316

「TDD Boot Camp Tokyo 2013-03」のお題です
Ruby
4
star
53

gemoire

Gemoire (Gem + grimoire) is YARD hosting app, like RubyDoc.info
Ruby
4
star
54

terraform-gcp-template

Terraform template for GCP
HCL
4
star
55

omniauth-chatwork

OmniAuth strategy for ChatWork
Ruby
4
star
56

pizza-beer

人数を入力するとピザ 🍕 とビール 🍻 の発注量を計算するツールです
JavaScript
4
star
57

go-doorkeeper

Doorkeeper API client for Go
Go
4
star
58

pretty-all-friends-birthday-calendar

プリティーシリーズに登場するキャラの誕生日をまとめたカレンダーぷり
Ruby
4
star
59

itamae-plugin-recipe-tmux

Itamae plugin to install tmux without any packages
Ruby
3
star
60

techbookfest5-itamae

「Packer with mitamae」のサンプルプロジェクト兼サポートページ
Ruby
3
star
61

syobocalite

Lite client for Syoboi calendar API
Ruby
3
star
62

sengiri_yaml

divide yaml file
Ruby
3
star
63

rubicure_api

API server for Rubicure
Ruby
3
star
64

kagaribi

Simple client for Cloud Firestore
Ruby
3
star
65

capistrano-around_chatwork

post to ChatWork before and after the specified task
Ruby
3
star
66

chatwork_mention_task

ChatWorkMentionTask can automatically task the mentions that came to you, easily look back on it later.
Ruby
3
star
67

azusaar_js

AZusaar!!のjsのソースです (サーバサイドのソースは別の所にあります)
JavaScript
3
star
68

github_stargazers_map

GitHubのリポジトリにstarつけた人の住所をGoogleマイマップで出すやつ
Ruby
3
star
69

prismdb-ruby

PrismDB API client for ruby
Ruby
2
star
70

cure-bots

Precure twitter bot
Ruby
2
star
71

kiriban_getter

Check number whether kiriban
Ruby
2
star
72

sue445

My profile repo
2
star
73

tweet_validator

[NO LONGER MAINTAINED] tweet length check validator
Ruby
2
star
74

my-ci-badges

List of OSSs I actively maintain
HTML
2
star
75

gcp-secretmanagerenv

Detect variable from environment variable or GCP Secret Manager
Go
2
star
76

tddbc-sapporo-pirka

TDD BootCamp札幌2.1のお題をSlim3+Scenic3+PirkaEngineで作ってみた
Java
2
star
77

gaerminal

run groovy script on your Google App Engine app
Java
2
star
78

faraday_boolean

Faraday response parser for boolean body
Ruby
2
star
79

datadog_thread_tracer

ddtrace helper to collect traces in thread
Ruby
2
star
80

tdd_blank

Java
1
star
81

kulib

My private library for Google App Engine
Java
1
star
82

mysql2-nested_hash_bind

mysql2 and mysql2-cs-bind extension to bind response to nested Hash
Ruby
1
star
83

itamae-plugin-recipe-omori_gohan

itamae tiny recipes
Ruby
1
star
84

rubocop-gemfile

USE Bundler/OrderedGems with rubocop v0.46.0+
Ruby
1
star
85

twitter_retry

Twitter api awesome handling with retry
Ruby
1
star
86

weekly-reporter

Java
1
star
87

tdd_ruby

Rubyの勉強のために「テスト駆動開発入門」をRubyで写経します
Ruby
1
star
88

asbc2014-tdd-js

JasmineのTDDのペアプロ内容です
JavaScript
1
star
89

gcp-kmsenv

Detect variable from environment variable or GCP Cloud KMS
Go
1
star
90

itest5ch

5ch (a.k.a. 2ch) reader via itest.5ch.net
HTML
1
star
91

tddjs_study

「テスト駆動JavaScript」の写経用
JavaScript
1
star
92

js-assertthat

use assertThat on JavaScript UnitTest
JavaScript
1
star
93

maven

My Maven Repository : )
1
star
94

itamae-plugin-recipe-tig

Itamae plugin to install tig
Ruby
1
star
95

s3tiger-test

s3tiger test project (deploy to appengine)
HTML
1
star
96

itamae-plugin-recipe-git_now

Itamae plugin to install git-now
Ruby
1
star
97

slides

Move to https://github.com/sue445/sue445/blob/master/slides.md
1
star
98

chatwork-preview

Simple ChatWork Preview
JavaScript
1
star
99

20110323

AppUrlsTester for scenic3
Java
1
star
100

itamae-plugin-recipe-consul

Itamae plugin to install Consul with init scripts
Ruby
1
star