Reputation: 355924
How can I go about generating an image of a database schema used in a Rails app?
Upvotes: 32
Views: 11625
Reputation: 373
For the sake of completeness there's ruby-toolbox/Rails_Class_Diagrams and besides rails-erd
it mentions railroady which looks abandoned, but still works now (at least with rails 8 and graphviz 12)
Upvotes: 0
Reputation: 997
try this ruby gem: https://voormedia.github.io/rails-erd
It will make a PDF, which you can also customize.
Upvotes: 0
Reputation: 15970
Have you tried rake db:schema:dump
?
Essentially, make sure that your database.yml
file is referencing the database you wish to dump, and then run the command. It'll take all of the tables and indexes in said database and then write it out to schema.rb
.
Note that you should rename schema.rb
once it contains the dump; otherwise, it could it overwritten.
Upvotes: 6