ER Diagram from SQL Schema and Migrations (draw.io)ER図の自動生成(SQL・マイグレーション・Prisma から draw.io)
ER Diagram is a free skill for PMDesk users that reads SQL migrations or a Prisma schema and draws an editable draw.io ER diagram, for Claude Code and Codex. It applies migrations in order, so later ALTER and DROP statements count, and marks relations without a foreign key as inferred.ER図 自動生成スキルです。SQL のマイグレーション、スキーマのダンプ、Prisma のスキーマを読み、draw.io で編集できる ER図を作ります(Claude Code / Codex 対応)。マイグレーションを順に適用するので、後から追加した ALTER や DROP も反映され、外部キーのない関係は推定として区別します。PMDesk ユーザーは無料です。
Free — no extra charge. Install it from the PMDesk app.無料(追加料金なし)。PMDesk アプリからインストールできます。
See it in action実際の出力例



Who it's forこんな方に
What it doesできること
ER Diagram turns the database schema in your repository into an ER diagram (ER図) you can hand to a client, and a document that says which relations are facts and which are guesses.
What you get:
- docs/design/er-diagram.drawio: an editable draw.io diagram in crow's foot notation, with primary and foreign keys, column types and a cardinality symbol on each end of every relation. Tables are laid out by a script, so the same schema always gives the same diagram and boxes do not overlap.
- docs/design/er-diagram.md: the table list, every relation with the file and line it comes from, inferred relations, dropped tables and columns, warnings, and questions for the system owner. PMDesk can comment on this file.
- An optional PNG, only after you agree, because it starts the draw.io desktop app. PMDesk previews PNG but not .drawio.
How it works: a script reads SQL files in file-name order and applies CREATE TABLE, ALTER TABLE, DROP and RENAME, so the final state is what gets drawn, including foreign keys added in a later migration. It also reads schema.prisma (PostgreSQL, MySQL and SQLite DDL are covered at the usual level). A column such as doctor_id with no foreign key is drawn as a dashed, inferred relation, never as a fact. Other ORMs (TypeORM, Sequelize, Django, Rails, SQLAlchemy) are read by the agent from the model code into the same format.
Limits: it reads local files only and never connects to a database, so it shows what the files say, not what runs in production. Views, functions and statements it cannot read are listed as warnings, not guessed. Large schemas are split into several diagrams by group of tables.
In our test sample, a clinic database in six migration files (9 live tables, 1 dropped table, 1 dropped column, 11 foreign keys), all three runs found all 11 foreign keys, including one added by a later ALTER TABLE, left out the dropped table and column, and drew the unconstrained doctor_id as a dashed inferred relation. A single run without the skill drew the dropped table and column, got the cardinality wrong on 2 of the 11 foreign keys and wrote no explanation document.
Drawing a different diagram? For use case, activity or state diagrams see the UML Diagrams skill. For infrastructure see the AWS Infra Diagram skill and the Azure Infra Diagram skill.
ER図 自動生成スキルは、リポジトリにあるデータベースのスキーマから、お客様に渡せる ER図を作り、どの関係が事実でどれが推測かを書いた説明書も残します。
できあがるもの:
- docs/design/er-diagram.drawio: 鳥の足記法の ER図(draw.io で編集可能)。主キー・外部キー・カラムの型、各関係の両端のカーディナリティを表示します。配置はスクリプトが決めるので、同じスキーマなら同じ図になり、テーブルが重なりません。
- docs/design/er-diagram.md: テーブル一覧、各リレーションとその根拠のファイル・行、推定リレーション、削除されたテーブルとカラム、警告、システム担当者への確認事項。PMDesk でコメントできます。
- PNG(任意): draw.io デスクトップアプリを起動するため、確認してから出力します。PMDesk は PNG をプレビューできますが .drawio は表示できません。
仕組み: スクリプトが SQL ファイルをファイル名の順に読み、CREATE TABLE・ALTER TABLE・DROP・RENAME を適用します。そのため最終状態が描かれ、後のマイグレーションで ALTER により追加された外部キーも漏れません。schema.prisma も読めます(PostgreSQL・MySQL・SQLite の一般的な DDL に対応)。doctor_id のように外部キー制約のない列は、事実ではなく破線の推定リレーションとして描きます。TypeORM、Sequelize、Django、Rails、SQLAlchemy などはエージェントがモデルのコードを読み、同じ形式に変換します。
制限: 読むのはローカルのファイルだけで、データベースには接続しません。図が示すのはファイルの内容であり、本番の状態とは限りません。ビュー・関数・読めなかった文は警告として載せ、推測では補いません。テーブルが多いスキーマはグループごとに複数の図に分けます。
検証用のサンプル(6 本のマイグレーションからなる診療所のデータベース。現存テーブル 9、削除済みテーブル 1、削除済みカラム 1、外部キー 11)では、スキルありの 3 回とも、後のマイグレーションで ALTER TABLE により追加された外部キーを含む 11 本すべてを検出し、削除済みのテーブルとカラムは図に含めず、制約のない doctor_id は破線の推定リレーションとして描きました。スキルなしの 1 回では、削除済みのテーブルとカラムが図に残り、外部キー 11 本のうち 2 本で多重度を誤り、説明書も作られませんでした。
ほかの図が必要な場合、ユースケース図・アクティビティ図・状態遷移図は UML Diagrams スキル、インフラ構成図は AWS Infra Diagram スキルと Azure Infra Diagram スキルをご利用ください。
How to use使い方
- Open the PMDesk app, go to Marketplace, open this skill and press Install.PMDesk アプリで「マーケットプレイス」を開き、このスキルを開いて「インストール」を押す
- Choose this project or this Mac.「このプロジェクト」か「このMac」を選ぶ
- Ask Claude Code or Codex to use the skill, then review the result in PMDesk.Claude Code または Codex にこのスキルを使うよう頼み、結果を PMDesk で確認する
Requirements必要なもの
- PMDesk (license or trial)PMDesk(ライセンスまたはトライアル)
- Claude Code or CodexClaude Code または Codex
- uv
Scripts in this skill含まれるスクリプト
scripts/drawio_lib.pyscripts/read_schema.py
The agent runs these only when it uses the skill, and asks for your permission first.エージェントはこのスキルを使うときにだけ実行し、実行前に許可を求めます。
FAQ
Does it connect to my database?
No. It only reads files in your repository: SQL migrations, schema dumps and schema.prisma. It needs no credentials and never runs psql, migrations or an ORM command. The diagram therefore shows what the files say, which may differ from the live database if someone changed it by hand.
Can it read many migration files with ALTER and DROP statements?
Yes. SQL files are applied in file-name order, so a table dropped in migration 5 or a foreign key added by ALTER TABLE in migration 6 is handled correctly, and only the final state is drawn. Dropped tables and columns are listed in the document so a reviewer can see they were left out on purpose.
Which ORMs and databases are supported?
A script reads SQL (common PostgreSQL, MySQL and SQLite DDL) and Prisma schemas. For TypeORM, Sequelize, Django, Rails schema.rb or SQLAlchemy, the agent reads the model code and fills the same model format by hand, and the document says so. Statements the script cannot read are listed as warnings.
What happens to relations that have no foreign key?
A column like doctor_id with no constraint is not treated as a fact. The skill lists it as a candidate, you or the agent decide, and an accepted one is drawn as a dashed edge marked inferred, with the reason in the document so the system owner can confirm it.
What if the schema has too many tables for one diagram?
Beyond about 30 tables the skill asks which group you want and draws one diagram per group, using the foreign-key connected groups and name prefixes. The document keeps a full table list, so nothing silently disappears.
Does it work with Codex, and is it free?
Yes to both. It is a standard skill (SKILL.md plus Python scripts run with uv), so Claude Code and Codex can use it, and it is free for PMDesk users. The output is a normal .drawio file you can open in draw.io, app.diagrams.net or the VS Code extension.
データベースに接続しますか?
接続しません。読むのはリポジトリ内の SQL マイグレーション、スキーマのダンプ、schema.prisma だけです。認証情報は不要で、psql やマイグレーション、ORM のコマンドも実行しません。そのため、図はファイルの内容を表すもので、誰かが本番を手で変更していた場合は実際の状態と異なることがあります。
ALTER や DROP を含む複数のマイグレーションファイルを読めますか?
読めます。SQL ファイルをファイル名の順に適用するので、5 番目のマイグレーションで削除したテーブルや、6 番目で ALTER TABLE により追加した外部キーも正しく扱い、最終状態だけを描きます。削除されたテーブルとカラムは説明書に一覧で載せるので、レビューする人は意図して図から外したことが分かります。
対応している ORM やデータベースは?
スクリプトが読めるのは SQL(PostgreSQL・MySQL・SQLite の一般的な DDL)と Prisma のスキーマです。TypeORM、Sequelize、Django、Rails の schema.rb、SQLAlchemy は、エージェントがモデルのコードを読んで同じ形式に手で変換し、説明書にもその旨を書きます。スクリプトが読めなかった文は警告として載せます。
外部キーがない関係はどうなりますか?
doctor_id のように制約のない列を事実として扱うことはありません。候補として挙げ、採用するかは利用者かエージェントが判断します。採用したものは破線の「推定」リレーションとして描き、根拠を説明書に書くので、システム担当者が確認できます。
テーブルが多すぎて 1 枚に収まらないときは?
約 30 テーブルを超えるときは、どのグループを描くか確認し、外部キーでつながるまとまりや名前の接頭辞でグループごとに 1 枚ずつ描きます。説明書にはすべてのテーブルの一覧を残すので、黙って抜け落ちることはありません。
Codex でも使えますか? 無料ですか?
どちらも対応しています。標準的なスキル(SKILL.md と uv で実行する Python スクリプト)なので Claude Code でも Codex でも使え、PMDesk ユーザーは無料です。出力は通常の .drawio ファイルで、draw.io、app.diagrams.net、VS Code の拡張機能で開けます。
Related関連
- UML Diagrams in draw.io: use case, activity, flowchart, swimlane and stateユースケース図・アクティビティ図・業務フロー図・状態遷移図を draw.io で作成
- Screen Flow Diagram from your frontend routes (draw.io)画面遷移図の作成(ルーティングと画面一覧から draw.io)
- Skills for Project leadsプロジェクトリード向けスキル
- Skills for FDE / contract developmentFDE・受託開発向けスキル
- Skills for PMs and reviewersPM・レビュアー向けスキル