Skip to content

Commit

Permalink
Merge pull request #1150 from jeremycline/schema-image
Browse files Browse the repository at this point in the history
Add a database schema image to the docs
  • Loading branch information
jeremycline committed Jan 17, 2017
2 parents 055626f + a4aefe1 commit 903acb2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,6 +12,7 @@ devel/ansible/playbook.retry
development.ini
dist
docs/_build
docs/images/database.png
MANIFEST
nosetests.xml
virtenv
Expand Down
4 changes: 4 additions & 0 deletions devel/ansible/roles/dev/tasks/main.yml
Expand Up @@ -8,6 +8,7 @@
- freetype-devel
- gcc
- git
- graphviz
- koji
- liberation-mono-fonts
- libffi-devel
Expand Down Expand Up @@ -35,6 +36,9 @@
- python2-fedmsg-consumers
- python2-flake8
- python2-nose-cov
# We can switch this to python2-sqlalchemy_schemadisplay once
# https://bodhi.fedoraproject.org/updates/FEDORA-2017-e54acedb77 is stable
- https://kojipkgs.fedoraproject.org//packages/python-sqlalchemy_schemadisplay/1.3/1.fc24/noarch/python2-sqlalchemy_schemadisplay-1.3-1.fc24.noarch.rpm
- redhat-rpm-config
- zlib-devel

Expand Down
19 changes: 12 additions & 7 deletions docs/Makefile
Expand Up @@ -14,7 +14,7 @@ ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext schema

help:
@echo "Please use \`make <target>' where <target> is one of"
Expand All @@ -40,18 +40,23 @@ help:

clean:
-rm -rf $(BUILDDIR)/*
-rm -rf images/

html:
schema:
@mkdir -p images
@./generate_db_schema

html: schema
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
dirhtml: schema
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
singlehtml: schema
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
Expand Down Expand Up @@ -90,19 +95,19 @@ devhelp:
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/bodhi"
@echo "# devhelp"

epub:
epub: schema
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
latex: schema
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
latexpdf: schema
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
Expand Down
13 changes: 13 additions & 0 deletions docs/developer_docs.rst
Expand Up @@ -257,3 +257,16 @@ As a privileged user on a Fedora system run the following:
::

sudo systemctl start postgresql.service


Database Schema
---------------

The Bodhi database schema can be seen below.

.. figure:: images/database.png
:align: center

Database schema.


22 changes: 22 additions & 0 deletions docs/generate_db_schema
@@ -0,0 +1,22 @@
#!/usr/bin/env python2
"""
Generate an image of the database schema
"""
from sqlalchemy_schemadisplay import create_schema_graph

from bodhi.server import models


def write_graph(filename):
graph = create_schema_graph(
metadata=models.metadata,
show_datatypes=False,
show_indexes=False,
rankdir='LR',
concentrate=False
)
graph.write_png(filename)


if __name__ == '__main__':
write_graph('images/database.png')

0 comments on commit 903acb2

Please sign in to comment.