mix ecto.gen.erd (ecto_erd v0.1.1) View Source

A mix task to generate an ERD (Entity Relationship Diagram) in a dot format

Examples

$ mix ecto.gen.erd
$ mix ecto.gen.erd --output-path=ecto_erd.dot
$ mix ecto.gen.erd && dot -Tpng ecto_erd.dot -o erd.png && xdg-open erd.png

See output and configuration examples in EXAMPLES group of PAGES section.

Command line options

  • --output-path - the path to the output file, defaults to ecto_erd.dot.
  • --config-path - the path to the config file, defaults to .ecto_erd.exs.

The configuration file

When running a mix ecto.gen.erd task, it tries to read a configuration file from the .ecto_erd.exs file in a current working directory. Configuration file must return a keyword list.

Options

  • :fontname - font name, defaults to Roboto Mono. Must be monospaced font if more than 1 column is displayed.
  • :columns - list of columns which will be displayed for each node (schema/source). Set to [] to hide fields completelly. Available columns: :name and :type. Defaults to [:name, :type].
  • :map_node - function which allows to remove the node from the diagram or to move the node to the cluster. Defaults to Function.identity/1, which means that all nodes should be displayed and all of them are outside any cluster. Use Ecto.ERD.Node.set_cluster/2 in this function to set a cluster. In order to remove the node, the function must return nil.
  • :otp_app - an application which will be scanned alongside with dependent applications in order to get a list of Ecto schemas. Defaults to Mix.Project.config()[:app]. You need to configure this option only if you run a task from umbrella root.

Default values can be represented as follows:

# .ecto_erd.exs
[
  fontname: "Roboto Mono",
  columns: [:name, :type],
  map_node: &Function.identity/1,
  otp_app: Mix.Project.config()[:app]
]