Generate an ERD as a CI build artifact
You can automatically generate ERD diagrams for Django models by installing the
django-extensions package, adding it to your
INSTALLED_APPS, and running
python manage.py graph_models -a (
-a for all models, or you can specify a specific subset). Then you can use something like
graphviz to generate an ERD from it.
requirements-dev.txt, and add it there. Then you should create a
settings folder with
production.py (and maybe a
staging.py in the future).
settings/development.py, you can do something like this:
INSTALLED_APPS += ( 'django-extensions', )``` The main reason to have a separate `settings/development.py` is to enable you to have separate things for your development and CI work. For example, you could have a Gitlab CI job that does something like ```before_script: - apt-get install -y graphviz whats-open-py3.7: image: library/python:3.7 type: test artifacts: paths: - erd.png expire_in: 1 week script: - python manage.py graph_models -a > erd.dot - dot -Tpng erd.dot -o erd.png```