Skip to content

Commit

Permalink
Dev dump (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
bamader authored Nov 26, 2024
1 parent dc72a08 commit c7d86ad
Show file tree
Hide file tree
Showing 23 changed files with 127,444 additions and 177,585 deletions.
1 change: 1 addition & 0 deletions query-connector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ COPY --from=installer /app/next.config.js .
COPY --from=installer /app/package.json .
COPY --from=installer /app/flyway/conf/flyway.conf ../flyway/conf/flyway.conf
COPY --from=installer /app/flyway/sql ../flyway/sql
COPY --from=installer /app/src/app/assets ./.next/server/app/assets

# Automatically leverage output traces to reduce image size
COPY --from=installer --chown=nextjs:nodejs /app/.next/standalone ./
Expand Down
19 changes: 19 additions & 0 deletions query-connector/VS_DUMP_INFO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## ValueSet SQL Dump Information

In order to make the dev process as low-lift as possible, we want to avoid executing the `db-creation` scripts when booting up the application in dev mode via `npm run dev`. To that end, we've created a `pg_dump` file containing all the valusets, concepts, and foreign key mappings that would be extracted from a fresh pull of the eRSD and processed through our creation functions. This file, `vs_dump.sql` has been mounted into the docker volume of our postgres DB when running in dev mode as an entrypoint script. This means it will be automatically executed when the DB is freshly spun up. You shouldn't need to do anything to facilitate this mounting or file running.

## Updating the pg_dump

If the DB extract file ever needs to be updated, you can use the following simple process:

1. Start up the application on your local machine using a regular `docker compose up`, and wait for the DB to be ready.
2. Load the eRSD and valuesets into the DIBBs DB by using the `Create Query` button on the `/queryBuilding` page. Optionally, use DBeaver to verify that valuesets exist in the database.
3. In a fresh terminal window, run

```
pg_dump -U postgres -f vs_dump.sql -h localhost -p 5432 tefca_db
```

If the above doesn't work, try replacing `localhost` with `0.0.0.0`.
4. Enter the DB password when prompted.
5. The extract file should now be created. It should automatically be located in `/query-connector`, but if it isn't, put it there.
2 changes: 2 additions & 0 deletions query-connector/docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
# DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db
# Note: you must have a local .env file with the ERSD_API_KEY set to a key
# obtained from the ERSD API at https://ersd.aimsplatform.org/#/api-keys
volumes:
- ./vs_dump.sql:/docker-entrypoint-initdb.d/vs_dump.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 2s
Expand Down
2 changes: 2 additions & 0 deletions query-connector/docker-compose-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=pw
- POSTGRES_DB=tefca_db
volumes:
- ./vs_dump.sql:/docker-entrypoint-initdb.d/vs_dump.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 2s
Expand Down
2 changes: 1 addition & 1 deletion query-connector/e2e/customize_query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test.describe("querying with the Query Connector", () => {
test.slow();
await expect(
page.getByText(
"249 labs found, 4 medications found, 104 conditions found.",
"250 labs found, 4 medications found, 104 conditions found.",
),
).toBeVisible();
await page.getByRole("link", { name: "Medications" }).click();
Expand Down
13 changes: 11 additions & 2 deletions query-connector/flyway/sql/V01_01__tcr_custom_query_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ CREATE TABLE IF NOT EXISTS conditions (
id TEXT PRIMARY KEY,
system TEXT,
name TEXT,
version TEXT
version TEXT,
category TEXT
);

CREATE TABLE IF NOT EXISTS category_data (
condition_name TEXT,
condition_code TEXT PRIMARY KEY,
category TEXT,
FOREIGN KEY(condition_code) REFERENCES conditions(id)
);

CREATE TABLE IF NOT EXISTS valuesets (
Expand All @@ -13,7 +21,8 @@ CREATE TABLE IF NOT EXISTS valuesets (
version TEXT,
name TEXT,
author TEXT,
type TEXT
type TEXT,
dibbs_concept_type TEXT
);

CREATE TABLE IF NOT EXISTS concepts (
Expand Down
175,314 changes: 0 additions & 175,314 deletions query-connector/flyway/sql/V01_02__load_tcr_data.sql

This file was deleted.

157 changes: 0 additions & 157 deletions query-connector/flyway/sql/V01_03__insert_hardcoded_values.sql

This file was deleted.

58 changes: 0 additions & 58 deletions query-connector/flyway/sql/V01_04__insert_tcr_default_queries.sql

This file was deleted.

Loading

0 comments on commit c7d86ad

Please sign in to comment.