-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SHEP-135] Add automatic generation of dbml file from schema on migra…
…tions (#300) ## References [SHEP-135](https://mozilla-hub.atlassian.net/browse/SHEP-135) ## Problem Statement We would like a way to better document the "total truth state" of our database after each migration is run. To do this, we propose dumping a `.dbml` file after each migration for better transparency on the total state of the database. ## Proposed Changes Two new steps have been added to the `make migrate` command. Namely: 1. After `python manage.py migrate`, a `pg_dump` command is run which saves the `.sql` representation of our database's schema to a schema.sql file. 2. After the `.sql` dump completes, we convert the sql to a dbml which is more friendly for humans to read, and can be easily dropped into [dbdiagram](https://dbdiagram.io/) for easy visualization. ## Verification Steps New dependencies required for running `sql2dbml` should be included as dev dependencies in the `package.json` file in the root directory. Verify the following: 1. `make install` correctly identifies the dev dependency and installs it 2. `make migrate` operates as normally expected _and_ a new file appears in the root directory named `schema.dmbl` 3. `make makemigrations` operates as normally expected and has the same behavior as 2. above. [SHEP-135]: https://mozilla-hub.atlassian.net/browse/SHEP-135?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
Showing
4 changed files
with
396 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.