bridge_troll icon indicating copy to clipboard operation
bridge_troll copied to clipboard

Generating an ERD (entity relationship diagram) for the project would help developers get started

Open jhsu802701 opened this issue 6 years ago • 6 comments

In my ruby_on_racetracks branch, I have rails-erd installed. When I run the command "bundle exec erd --attributes=foreign_keys,primary_keys,timestamps,inheritance,content --filetype=dot --filename=tmp/diagram-models --inheritance --notation=bachman dot -Tjpg tmp/diagram-models.dot", I get the following error messages:

Loading application in 'bridge_troll'...
Generating entity-relationship diagram for 26 models...
Warning: Ignoring invalid association :role on Rsvp (model Role exists, but is not included in domain)
Warning: Ignoring invalid association :volunteer_assignment on Rsvp (model VolunteerAssignment exists, but is not included in domain)
Warning: Ignoring invalid association :operating_system on Rsvp (model OperatingSystem exists, but is not included in domain)
Warning: Ignoring invalid association :volunteer_preference on Rsvp (model VolunteerPreference exists, but is not included in domain)
Diagram saved to 'tmp/diagram-models.dot'.
Error: in routesplines, cannot find NORMAL edge
Segmentation fault (core dumped)

jhsu802701 avatar Feb 09 '19 20:02 jhsu802701

rails-erd seems to have difficulty with ActiveHash::Base types.

jhsu802701 avatar Feb 09 '19 22:02 jhsu802701

I like the idea of generating an entity relationship diagram. I wonder if this is something that is a bug in rails-erd and ActiveHash...

IIRC, ActiveHash isn't actually stored in the database, but gets its data from a yaml, so it may be something not yet supported by rails-erd

ultrasaurus avatar Mar 24 '19 15:03 ultrasaurus

I got this working. First I checked to see if PDF output works:

  • Following the README for rails-erd I first installed Graphviz with brew install graphviz
  • I added the following lines to my Gemfile in group :development do:
   gem 'rails-erd'
   gem 'ruby-graphviz'
  • Then I ran bundle install, bundle exec rails-erd and it generated a pdf file. I did get warnings similar to those above, but it completed successfully.

erd.pdf

Then I tried the query as posted in the original post; it generated the diagram-models.dot file and also spewed a bunch of binary data into my terminal. I amended the command to redirect the output to a jpg and that jpg is valid. So, the command I ran was bundle exec erd --attributes=foreign_keys,primary_keys,timestamps,inheritance,content --filetype=dot --filename=tmp/diagram-models --inheritance --notation=bachman dot -Tjpg tmp/diagram-models.dot > thing.jpg and I got below as results:

thing (And a .dot file GitHub doesn't support)

How would y'all like to proceed? Do we just want these docs for people to read, or do we want to build this functionality into the project?

nerual avatar Jul 04 '19 16:07 nerual

Build the functionality into the project, but keep the outputs out of the source code in the interest of keeping the code base small.

jhsu802701 avatar Jul 05 '19 05:07 jhsu802701

Can you describe in greater detail how you envision that working? Do we install Graphviz as a requirement of the project and include a wrapper script that executes that command, and some documentation explaining to open the resulting jpg?

nerual avatar Jul 18 '19 19:07 nerual

After discussing with @nerual, we were not sure of the benefits of including this feature in the project without extensive training on how to use it and for what instances. It seems like this feature request is an individual preference rather than in the scope of the needs of the Bridge Troll project. In the interest of keeping the development gemset lean, we would prefer not to include this if only one contributor would be using it once to generate a document.

An option is for @jhsu802701 to create a pull request documenting how one would generate this document following the steps @nerual outlined above as a resource for any new developers.

rachelober avatar Aug 01 '19 17:08 rachelober