Created
November 14, 2019 19:02
-
-
Save mgwalker/0126e643100df55a0f7f442e8edfa6a1 to your computer and use it in GitHub Desktop.
PostgreSQL dumps into DOT files or PNGs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker exec <database image> pg_dump -s -U <database username> <database name> | \ | |
# Strip out the namespace because graphviz doesn't know what to do with it | |
sed 's/ public\./ /g' | \ | |
# Turn that thing into a DOTfile! | |
docker run -i --rm mgwalker/sql_graphviz:1.0 > docs/database-diagram.dot | |
docker exec <database image> pg_dump -s -U <database username> <database name> | \ | |
# Strip out the namespace because sql_graphviz doesn't know what to do with it | |
sed 's/ public\./ /g' | \ | |
# Turn that thing into a DOTfile | |
docker run -i --rm mgwalker/sql_graphviz:1.0 | \ | |
# And then into a PNG! | |
docker run -i --rm fgrehm/graphviz dot -Tpng > docs/database-diagram.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment