Postgres ERD is a program that allows you to easily generate a diagram based on a postgresql database schema. The diagram gives an overview of how your tables are related. Having a diagram to describes your tables is perfect for documentation.
Postgres ERD is heavily inspired by Rails ERD but it serves some different use cases. First and foremost it does not rely on Rails (like Rails ERD). Thus you can use it for any database schema regardless of your project's language.
- Ruby 2.4+
- postgresql
It's part of a two-step program:
Install the gem
gem install pg-erd
Use the thing:
pg-erd {{the-name-of-your-database}}
This will output a diagram of your database in dot format. You can save it
pg-erd {{the-name-of-your-database}} > my-awesome-database.dot
... or run it though graphviz to create a png file:
pg-erd {{the-name-of-your-database}} | dot -Tpng > erd.png
... which you may also do like this:
pg-erd --title "Secret Project X" --format png {{the-name-of-your-database}} > erd.png
There are many more formats and a few more useful options. You can find them all with --help
This command will create an ERD for every database on your system. It will write many image files, one for each database, to the current directory.
Like ls
but it lists the names of your postgres databases one by one.
This command outputs a summary of your database structure to the console. It shows the same information as an ERD but then in plain text.