fuelen / ecto_erd

A mix task for generating Entity Relationship Diagram from Ecto schemas available in your project.
Apache License 2.0
209 stars 13 forks source link

[Suggestion] Add blurb for how to tie ecto_erd into migrations #56

Open kieraneglin opened 2 months ago

kieraneglin commented 2 months ago

I want my ERD file to always be up-to-date and don't have to have to remember to run it each time. For that, I've added two entries to the aliases method in my mix.exs:

"ecto.migrate": [
  "ecto.migrate",
  "ecto.gen.erd --output-path=priv/repo/ecto_erd.dot",
  "cmd dot -Tpng priv/repo/ecto_erd.dot -o priv/repo/erd.png"
],
"ecto.rollback": [
  "ecto.rollback",
  "ecto.gen.erd --output-path=priv/repo/ecto_erd.dot",
  "cmd dot -Tpng priv/repo/ecto_erd.dot -o priv/repo/erd.png"
]

These regenerate the ERD every time I migrate or rollback the database. I imagine I'm not the only one who benefits from this so I thought I'd mention in case you wanted to add something like this to the README!

fuelen commented 2 months ago

PR is welcome!

fuelen commented 2 months ago

It would be great if you add this both to README and to moduledoc of Mix.Tasks.Ecto.Gen.Erd