Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rotorsoft/issue5293 - Create a shell script to read the current database schema and generate a mermaid ERD in the wiki space #5294

Merged
merged 4 commits into from
Oct 12, 2023

Conversation

Rotorsoft
Copy link
Contributor

Link to Issue

Closes: #5293

Description of Changes

  • created sql query to read pg metadata and generate mermaid erd schema
  • created shell script to save results in wiki/ERD.md

Test Plan

  • Execute yarn workspace commonwealth db-doc to generate a fresh copy of ./knowledge_base/wiki/ERD.md

Other Considerations

  • not integrated in the ci/cd pipeline yet, can be added to db-all script if necessary

Roger Torres added 2 commits October 12, 2023 12:43
@gdjohnson gdjohnson self-assigned this Oct 12, 2023
Copy link
Contributor

@gdjohnson gdjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! Super cool idea elegantly implemented.

My only big-picture concern is that it's such an enormous ERD, it's difficult to view or navigate visually. Curious if you have any advice, or what you've been using to visually navigate the generated ERD.

packages/commonwealth/package.json Outdated Show resolved Hide resolved
knowledge_base/wiki/ERD.md Outdated Show resolved Hide resolved
packages/commonwealth/scripts/gen-mermaid-erd.sh Outdated Show resolved Hide resolved
@rbennettcw
Copy link
Contributor

Nice.

Looks like the script assumes that Postgres is running directly on the host machine? For those of us who run Postgres in Docker (Compose) it would be nice to have a script (or documentation including the script) that can work in that context.

@Rotorsoft
Copy link
Contributor Author

Nice.

Looks like the script assumes that Postgres is running directly on the host machine? For those of us who run Postgres in Docker (Compose) it would be nice to have a script (or documentation including the script) that can work in that context.

I also run PG in docker, it should work unless you are using a different PG config.
Assuming the standard I found for local dev, but can be modified to use .env

@Rotorsoft
Copy link
Contributor Author

This is awesome! Super cool idea elegantly implemented.

My only big-picture concern is that it's such an enormous ERD, it's difficult to view or navigate visually. Curious if you have any advice, or what you've been using to visually navigate the generated ERD.

I normally use the mermaid live editor - https://mermaid.live , but the Github integration should be good enough. There is also the Miro and VSCode integrations... https://mermaid.js.org/ecosystem/integrations-community.html

@rbennettcw
Copy link
Contributor

Nice.
Looks like the script assumes that Postgres is running directly on the host machine? For those of us who run Postgres in Docker (Compose) it would be nice to have a script (or documentation including the script) that can work in that context.

I also run PG in docker, it should work unless you are using a different PG config. Assuming the standard I found for local dev, but can be modified to use .env

Do you have psql installed on the host?

@Rotorsoft
Copy link
Contributor Author

Nice.
Looks like the script assumes that Postgres is running directly on the host machine? For those of us who run Postgres in Docker (Compose) it would be nice to have a script (or documentation including the script) that can work in that context.

I also run PG in docker, it should work unless you are using a different PG config. Assuming the standard I found for local dev, but can be modified to use .env

Do you have psql installed on the host?

yes

@gdjohnson
Copy link
Contributor

Looks like a minor merge conflict, otherwise looks good from a documentation perspective, thanks for the swift changes.

I wasn't having great luck with an ERD this size using Matt Bierner's Markdown Mermaid Support extension for VSCode, but I'll give the official Mermaid extension a shot. Either way, a minor consideration.

@gdjohnson gdjohnson merged commit 4621c94 into master Oct 12, 2023
@gdjohnson gdjohnson deleted the Rotorsoft/issue5293 branch October 12, 2023 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create script to automatically generate a mermaid ERD in the docs wiki after database migrations
3 participants