Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DB diagram function to Makefile #1146

Merged
merged 35 commits into from
Jan 16, 2025

Conversation

michplunkett
Copy link
Collaborator

@michplunkett michplunkett commented Jan 15, 2025

Fixes issue

#1060

Description of Changes

Added a command to the Makefile that generates a DB relationship diagram.

Tests and Linting

  • This branch is up-to-date with the develop branch.
  • Ran make create_db_diagram command.
  • pytest passes on my local development environment.
  • pre-commit passes on my local development environment.
  • Validated edge cases for make create_db_diagram.
(env) michaelp@Mac OpenOversight % rm database/schema.dot
(env) michaelp@Mac OpenOversight % make create_db_diagram
# Create new dot file showing current version of schema
eralchemy -i postgresql://openoversight:terriblepassword@localhost/openoversight-dev -o database/schema.new.dot
# Sort new version of schema file
sort database/schema.new.dot -o schema.new.dot.sorted
# Create old schema file if it does not exist and then sort it
touch database/schema.dot
sort database/schema.dot -o schema.dot.sorted
# Create a new diagram if there are changes, otherwise clean up files
Detected schema changes, making new DB relationship diagram!
# Remove all sorted files
rm schema.dot.sorted schema.new.dot.sorted
(env) michaelp@Mac OpenOversight % make create_db_diagram
# Create new dot file showing current version of schema
eralchemy -i postgresql://openoversight:terriblepassword@localhost/openoversight-dev -o database/schema.new.dot
# Sort new version of schema file
sort database/schema.new.dot -o schema.new.dot.sorted
# Create old schema file if it does not exist and then sort it
touch database/schema.dot
sort database/schema.dot -o schema.dot.sorted
# Create a new diagram if there are changes, otherwise clean up files
No schema changes detected!
# Remove all sorted files
rm schema.dot.sorted schema.new.dot.sorted
(env) michaelp@Mac OpenOversight %

@michplunkett michplunkett self-assigned this Jan 15, 2025
@michplunkett michplunkett linked an issue Jan 15, 2025 that may be closed by this pull request
@@ -9,7 +9,7 @@ ENV DISPLAY=:1
ENV PYTHONDONTWRITEBYTECODE=1

# install apt dependencies
RUN apt-get update && apt-get install -y xvfb libpq-dev python3-dev && \
RUN apt-get update && apt-get install -y xvfb libpq-dev python3-dev graphviz-dev graphviz && \
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

graphviz-dev adds all of the C packages needed to compile graphviz.

@michplunkett michplunkett marked this pull request as ready for review January 16, 2025 01:21
@michplunkett michplunkett merged commit 189d9a5 into develop Jan 16, 2025
4 checks passed
@michplunkett michplunkett deleted the automatically-create-database-diagrams branch January 16, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create automated means of updating the DB diagram
2 participants