How to regenerate the ER diagram¶
In the docs there is an autogenerated ER diagram showing the Django models as SQL tables, relations and fields. Whenever tables, fields and relations are added, changed or removed this diagram should be regenerated.
Get dependencies¶
You need to have installed the development dependencies to regenerate the diagram:
pip install argus-server[dev]
This will install django_extensions
which has the diagram generator we use.
Test by making a .dot-file¶
To test if everything is installed correctly, run:
python manage.py graph_models argus_auth argus_incident argus_notificationprofile \
--group-models -X Permission,AbstractBaseUser,PermissionsMixin
This will dump a .dot-file, the textual representation of the graph, to standard out.
Generate PNG¶
In order to generate a PNG there are two methods:
Generate via the
graph_models
command and one more dependencyUse
graphviz
directly on a .dot-file
Generate via the graph_models
command¶
We need to have one more dependency installed: one of pygraphviz
or
pydotplus
. If one cannot be installed via pip, try the other.
To generate the final PNG in the correct location, run:
python manage.py graph_models argus_auth argus_incident argus_notificationprofile \
--group-models -X Permission,AbstractBaseUser,PermissionsMixin \
-o docs/reference/img/ER_model.png
Use graphviz
directly on a .dot-file¶
Make sure you have graphviz installed, how is OS/distro dependent
Generate the dot-file with:
python manage.py graph_models argus_auth argus_incident argus_notificationprofile \ --group-models -X Permission,AbstractBaseUser,PermissionsMixin \ -o ER_model.dot
Generate the PNG with
dot
:dot -T png -o docs/reference/img/ER_model.png ER_model.dot
You can now delete
ER_model.dot
Commit!¶
Commit the new image with a message like “Sync the ER diagram to current database schema”.