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

Create automated means of updating the DB diagram #1060

Closed
michplunkett opened this issue Sep 15, 2023 · 0 comments · Fixed by #1146
Closed

Create automated means of updating the DB diagram #1060

michplunkett opened this issue Sep 15, 2023 · 0 comments · Fixed by #1146

Comments

@michplunkett
Copy link
Collaborator

michplunkett commented Sep 15, 2023

What issue are you seeing?

Currently we have to use either an IDE or web application to create our DB diagrams. It'd be great to use something like this to create our DB diagrams and to make sure that the diagram is always up-to-date via a CI process: https://gist.github.com/edgarrmondragon/49de4263cecc5bb98577eaa5bbcad807

cc: @sea-kelp

@michplunkett michplunkett self-assigned this Sep 15, 2023
@michplunkett michplunkett changed the title Create automated means of creating DB diagrams Create automated means of updating the DB diagram Sep 15, 2023
@michplunkett michplunkett removed their assignment Jan 3, 2024
@michplunkett michplunkett linked a pull request Jan 15, 2025 that will close this issue
5 tasks
michplunkett added a commit that referenced this issue Jan 16, 2025
## Fixes issue
#1060

## Description of Changes
Added a command to the `Makefile` that generates a DB relationship
diagram.

## Tests and Linting
- [x] This branch is up-to-date with the `develop` branch.
- [x] Ran `make create_db_diagram` command.
- [x] `pytest` passes on my local development environment.
- [x] `pre-commit` passes on my local development environment.
- [x] Validated edge cases for `make create_db_diagram`.

```console
(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 %
```
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 a pull request may close this issue.

1 participant