diff --git a/.gitignore b/.gitignore index d03edf5..69bc636 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ pgdata/ .gitsecret/keys/random_seed !*.secret -db/backups/*.tar.gz diff --git a/.gitsecret/paths/mapping.cfg b/.gitsecret/paths/mapping.cfg index 0552346..46083e8 100644 --- a/.gitsecret/paths/mapping.cfg +++ b/.gitsecret/paths/mapping.cfg @@ -1 +1 @@ -db/backups/20200408.tar.gz:b4f973f283312971e9850e1b8cc58fcbdec518b76b6f7a52a5a3beb2fb45bdee +db/backups/20200408.sql.gz:b365bf5fc13dbbe26d93e88f6523451b092999edc2a3f0680482f3a7e7369468 diff --git a/db/json_from_fmp.py b/db/.old/json_from_fmp.py similarity index 100% rename from db/json_from_fmp.py rename to db/.old/json_from_fmp.py diff --git a/db/postgres_init_from_json.py b/db/.old/postgres_init_from_json.py similarity index 100% rename from db/postgres_init_from_json.py rename to db/.old/postgres_init_from_json.py diff --git a/db/postgres_seed_from_json.py b/db/.old/postgres_seed_from_json.py similarity index 100% rename from db/postgres_seed_from_json.py rename to db/.old/postgres_seed_from_json.py diff --git a/db/seed_postgres.py b/db/.old/seed_postgres.py similarity index 100% rename from db/seed_postgres.py rename to db/.old/seed_postgres.py diff --git a/db/README.md b/db/README.md index 306c4fb..820f0d3 100644 --- a/db/README.md +++ b/db/README.md @@ -1,5 +1,17 @@ # Database Management +How to load a backup into your postgres docker container + +First, decrypt the pg_dump files. +``` +git secret reveal +``` +Second, restore the pg_dump into the container. +```bash +gunzip -c ./backups/version.sql.gz | docker exec -i hdhs_database_1 psql -U postgres -d app_db +``` + +## Running Notes generate backups: ```bash @@ -8,7 +20,7 @@ docker exec hdhs_database_1 pg_dump -U postgres app_db | gzip > backups/20200408 Enter database container ```bash -docker-compose -f dev-docker-compose.yml run database bash +docker-compose -f dev-docker-compose.yml run database bash ``` Enter DB inside container diff --git a/db/backups/.gitignore b/db/backups/.gitignore new file mode 100644 index 0000000..bdf5868 --- /dev/null +++ b/db/backups/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!*.secret \ No newline at end of file diff --git a/db/backups/20200408.sql.gz.secret b/db/backups/20200408.sql.gz.secret new file mode 100644 index 0000000..a39a65e Binary files /dev/null and b/db/backups/20200408.sql.gz.secret differ diff --git a/db/backups/20200408.tar.gz.secret b/db/backups/20200408.tar.gz.secret deleted file mode 100644 index 0825eec..0000000 Binary files a/db/backups/20200408.tar.gz.secret and /dev/null differ diff --git a/db/result.pkl b/db/result.pkl deleted file mode 100644 index e69de29..0000000 diff --git a/db/test_edit_distance.py b/db/test_edit_distance.py deleted file mode 100644 index f79c520..0000000 --- a/db/test_edit_distance.py +++ /dev/null @@ -1,13 +0,0 @@ -import pandas as pd - -from fmp import FMP - -fmp_model = FMP("20200303_chihaiti", "hjohnson", "hjohnson") - -pk_visit_id = "pk_visit_id" -fk_clinic_id = "fk_clinic_id" - -print(fmp_model.get_tablename_from_fieldname(pk_visit_id)) # expect this to be "visits" -print( - fmp_model.get_tablename_from_fieldname(fk_clinic_id) -) # expect this to be "clinics"