Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
人魚とたわむれる
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
muryoimpl
August 16, 2025
Programming
71
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
人魚とたわむれる
Kanazawa.rb meetup #156 祝13周年 LT大会 (石川県立図書館) でやった LT資料。
muryoimpl
August 16, 2025
More Decks by muryoimpl
See All by muryoimpl
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
2.5k
Kanzawa.rbのLT大会を支える技術の裏側を変更する Ruby on Rails + Litestream 編
muryoimpl
0
2.4k
Kanazawa.rb LT大会用/kzlt コマンドの説明 2024/01版
muryoimpl
0
3.1k
kzltコマンドの新たなソリューションについて
muryoimpl
0
3.1k
俺とTODOアプリ~Linearの変~
muryoimpl
0
2.9k
POSIX文字クラスでの躓き
muryoimpl
0
2.4k
/kzlt コマンドとは
muryoimpl
0
1.1k
meetup.kzrb.org の更新を考える 事前激闘編
muryoimpl
0
1.7k
meetup.kzrb.org の更新を 考える ゆるふわ編
muryoimpl
0
1.7k
Other Decks in Programming
See All in Programming
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
910
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
750
Workers Cache を知る
syumai
0
340
setup-vp GitLab対応の裏側
naokihaba
0
150
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
190
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
480
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
330
R8 の設定見直しでアプリサイズ削減
andpad
0
160
contenteditable と日本語入力に向き合う
colorful12
0
140
Jetpack Compose Mechanisms
skydoves
2
430
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
440
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.4k
Featured
See All Featured
The Language of Interfaces
destraynor
162
27k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
300
Darren the Foodie - Storyboard
khoart
PRO
4
4k
RailsConf 2023
tenderlove
30
1.6k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.1k
What's in a price? How to price your products and services
michaelherold
247
13k
Paper Plane (Part 1)
katiecoart
PRO
2
11k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
570
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
860
Transcript
人魚とたわむれる Kanazawa.rb meetup #156 祝13周年 LT 大会 石川県立図書館 2025-08-16(Sat) muryoimpl
ある日、DB項目ないの? テーブルに何もってるか知りたいんだけど と、言われる
ないんだわ、これが • 継続的成長を義務付けられたソフトウェアについては、項目書作ったときから陳腐 化する • 生温かい手で作ると工数がとんでもなくかかる • 上記理由から、人類が一から頑張ってつくるものではない そうか、自動生成か …となる
調べると gem はありそうだが … • erd や rails-mermaid_erd 、rails-mermaid_erd_markdown など今使われていそう
な gem はある • ただし、大量のテーブルがあるシステムで、グループ化して表示できないと見づら い。とても見づらい。 • 中身を見ると、オープンクラスを駆使して手を入れるにも改造しにくそうな作りになっ てる • インフラ構築を前提とした環境にしたくないな。 • 出力対象外にしたいテーブルがある。日本語名も併記したい
やはり自作するしかないか!
DB情報からテーブルと関連の情報を作って出力するぞ • モデル とモデル同士の関連の情報から、mermaid の ER図を、日本語併記で出力 する • 普段は Notion
を使っているので、Notion のページに language: mermaid として 記述する ◦ 定期実行で更新できそうだしよさそう • i18n の日本語辞書を使い、翻訳がある場合はそれを併記する • ER図にしたのは、クラス図と違ってカラムを足すことができるため ◦ 追加したカラムに日本語名を出す
というので作った https://gist.github.com/muryoimpl/1 d2f325e11074529dab55011967b91b2 TODO: 後でSlack に貼るぞい
つくりはこんな感じ • ApplicationRecord を継承したモデル(テーブルに対応したモデル)を抽出する • column でカラム情報、relations で関連情報を抽出する • i18n
でテーブル、カラムの日本語名を当てる。なければ日本語名を出さない • 設定YAML で、グループ化と無視するテーブルを指定する • has_many, has_one, belongs_to から関連する線の種類を判別して出力する • 一旦、Notion 反映は待って、単純にグループ毎に markdown を出力する
erDiagram "channels: channel" { integer id "" string name "channel名"
string slack_channel_id "チャネルID" integer workspace_id "ワークスペースID" datetime created_at "作成日時" datetime updated_at "更新日時" } "entries: エントリー" { integer id "" string title "発表タイトル" integer status "ステータス" integer channel_id "チャネルID" integer user_id "発表者" datetime created_at "作成日時" datetime updated_at "更新日時" } "users: 発表者" { integer id "" string name "ユーザー名" string slack_user_id "user_id" datetime created_at "作成日時" datetime updated_at "更新日時" } "workspaces: workspace" { integer id "" string name "ワークスペース名" datetime created_at "作成日時" datetime updated_at "更新日時" string slack_team_id "team_id" } "channels: channel" ||--o{ "entries: エントリー" : "" "users: 発表者" ||--o{ "entries: エントリー" : "" "workspaces: workspace" ||--o{ "channels: channel" : ""
erd_mermaid.yml にgroupsに配列を渡 すことで複数のテーブルをグループ化し、 別々のファイルに出力することができる ```yaml groups: environment: - workspaces -
channels entries: - users - entries ```
感想 • has_and_belongs_to_many は未対応で、本体は 300 行くらいで実装できた • モデル情報と関連情報を扱うモデル、出力モデルを分けると、複数の出力形式に 対応できそうですね。 •
i18n 対応と、mermaid で日本語を扱うときの制限が辛かった ◦ 日本語は “あああ” のようにダブルクウォートで囲む必要がある ◦ 関連に名前を付けるの必須だと!? ただし、”” で空文字にできる ◦ Notionだと、direction 指定が使えない。(オブジェクトとして判定されちゃった) • 早くNotion連携版を作らねばならぬ
2につづく