-
Notifications
You must be signed in to change notification settings - Fork 3
Loading deployed data locally
Dan Guy edited this page Jul 30, 2025
·
2 revisions
When debugging issues that arise on Dev, Stage, and Test, we may need to pull down the data from the database to debug locally. One way of achieving this is to psql dump the database and load it in docker.
- Authenticate.
cf login -a api.fr.cloud.gov --sso - Connect to database and dump a copy
- Install cf connect plugin https://cloud.gov/docs/services/relational-database/#using-cf-service-connect-plugin
cf connect-to-service -no-client fecfile-web-api fecfile-api-rds- pull a copy of the database:
pg_dump ("Name" from ssh window) --host=("Host" from ssh window) --port=("Port" from ssh window) --username=("Username" from ssh window) > ~/<space>_dump_<date>.sqlYou will be prompted for a password
- Prepare .sql file
- Because the connect plugin sets the owner to the user that did the pull, we'll run into problems when running the .sql because that user wont exist.
- Replace all instances of that username with
postgres, i.e.sed -i 's/<"Username">/postgres/g' <dump file>.sql- NOTE: look into
--no-ownerflag for pg_dump to avoid this issue
- NOTE: look into
- Move your dump file into
fecfile-web-api/db/
- Load into docker
- Add
COPY <space>_dump_<date>.sql /docker-entrypoint-initdb.d/1.sqltodb/Dockerfile - Run
docker compose downthendocker compose build --no-cache. Both are important. Running just one or the other will prevent the db from loading how you want it to. - Make the test user the committee administrator of the committee you want to troubleshoot by adding the following to
django-backend/fixtures/e2e-test-data.json:
- Add
...},
{
"model": "committee_accounts.Membership",
"pk": "abcd1234-06c1-42b7-a379-274d84535526",
"fields": {
"role": "COMMITTEE_ADMINISTRATOR",
"committee_account_id": "<uuid of committee account>",
"user_id": "e100e1da-cbfc-4189-aece-d139048a8e0a",
"pending_email": null,
"created": "2022-02-09T00:00:00.000Z",
"updated": "2022-02-09T00:00:00.000Z"
}
}
Run docker compose up and your data should be available