generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into story-672-no_rs_history_api
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# 16. Postgres Database | ||
|
||
Date: 2024-01-08 | ||
|
||
## Decision | ||
|
||
We will use a Postgres database for storage of project data that needs to persist across restarts. | ||
|
||
## Status | ||
|
||
Accepted | ||
|
||
## Context | ||
|
||
Postgres is an open-source, relational, SQL database. It provides a proven and robust feature set in the base implementation as well as add ons if specific features are required. Postgres is also well-supported by the community. | ||
[Reference](https://www.postgresql.org/docs/) | ||
|
||
### Related Issues | ||
|
||
- 672 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Database | ||
|
||
## Requirements | ||
Choose a Postgres client, [pgAdmin](https://www.pgadmin.org/) is the most full featured, intelliJ also has a built in plugin. | ||
|
||
## Connecting to Local Database | ||
1. Run the docker file ./docker-compose.postgres.yml in the root of the project | ||
2. Run the `generate_env.sh` script: | ||
|
||
```bash | ||
./generate_env.sh | ||
``` | ||
|
||
3. Run the `./gradlew clean app:run` command in your terminal | ||
4. Configure your preferred db client to connect to the database with the connection information. NOTE: The database runs on the non-default port of `5433` to avoid collision with the ReportStream Postgres database. | ||
5. Grab the create table command from [line 77 of this project file](.github/workflows/terraform-deploy_reusable.yml) from after the -c to the first semi-colon, no need for the `ALTER TABLE` statements and run it in your local postgres instance to create the table | ||
6. Upon creating the table for the first time you may have to instruct your client to refresh (In pgAdmin right-click on the left hand menu and select Refresh) | ||
|
||
## Connecting to an Azure Hosted Database | ||
1. Install the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) | ||
2. Open the azure environment you are trying to access from within your browser and navigate to the database | ||
3. Inside of the Azure database page select the Networking option from the left hand nav | ||
4. Click the link that says `Add current client IP address` and then save the page | ||
1. NOTE: You should only add your local IP address on a temporary basis, you should remove it after the verification is complete | ||
5. On the left hand navigation select Authentication and select the `Add Microsoft Entra Admins` link to add your user to the list | ||
1. NOTE: This permission should only be added temporarily and removed after you are finished with verification | ||
6. Enter new connection settings from Azure into your db client of choice | ||
1. Password will come from step 8 of these instructions and can be left blank | ||
7. Run `az login` inside of your local terminal | ||
8. Run `az account get-access-token --resource https://ossrdbms-aad.database.windows.net` to get a temporary password | ||
|
||
## Modifying the database schema | ||
To modify the schema there are a few locations in the code we need to update. | ||
1. [Line 77 of this file contains the table creation statements](.github/workflows/terraform-deploy_reusable.yml) To modify column data types or add or remove columns, go there. | ||
2. The `PostgresDao.java` contains our queries for the database. Remember to update both the save and the fetch methods | ||
3. `DatabasePartnerMetadataStorage` is what calls our dao to perform the db operation, you will need to update the inputs here |