Skip to content

Commit

Permalink
feat: add data/preview_env_seed.psql and import in preview envs
Browse files Browse the repository at this point in the history
Add sql seed file for preview envs to provide useful data
e.g. areas without having to run slow import commands.
  • Loading branch information
joaquimds committed Dec 11, 2024
1 parent 4a396ab commit eea6166
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __pycache__
.media
data/**/*
!data/.gitkeep
!data/preview_env_seed.zip
.next

conf/env
Expand Down
25 changes: 17 additions & 8 deletions bin/ck_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/bash

# NB: Keep the resulting database state up to date with data/post_ck_setup_db_export.psql
# (excluding the `python manage.py seed` command) in order to keep the preview environments
# in-sync with the dev environments.

echo '';
echo '------------------------------------';
echo '';
Expand Down Expand Up @@ -32,14 +37,6 @@ python manage.py migrate
python manage.py createcachetable
echo "Done"

echo '';
echo '------------------------------------';
echo '';
echo 'Seeding database...';
echo '';
echo '------------------------------------';
python manage.py seed

echo '';
echo '------------------------------------';
echo '';
Expand All @@ -65,6 +62,14 @@ curl 'https://researchbriefings.files.parliament.uk/documents/CBP-10009/HoC-GE20
-o data/2024_general_election.csv
python manage.py import_last_election_data

echo '';
echo '------------------------------------';
echo '';
echo 'Seeding database...';
echo '';
echo '------------------------------------';
python manage.py seed

echo '';
echo '------------------------------------';
echo '';
Expand All @@ -82,3 +87,7 @@ echo '';
echo 'Setup complete!';
echo '';
echo '------------------------------------';

# NB: Keep the resulting database state up to date with data/post_ck_setup_db_export.psql
# (excluding the `python manage.py seed` command) in order to keep the preview environments
# in-sync with the dev environments.
Binary file added data/preview_env_seed.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
web:
image: mysociety/local-intelligence-hub:${TAG:-latest}
build: .
command: /app/script/server --development
command: .venv/bin/python manage.py runserver 0.0.0.0:8000
volumes:
- .:/app
depends_on:
Expand Down
7 changes: 6 additions & 1 deletion render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ services:
# SEED_AIRTABLE_PLEDGELIST_API_KEY, SEED_AIRTABLE_PLEDGELIST_BASE_ID, SEED_AIRTABLE_PLEDGELIST_TABLE_NAME
# SEED_AIRTABLE_DATASOURCE_API_KEY, SEED_AIRTABLE_DATASOURCE_BASE_ID, SEED_AIRTABLE_DATASOURCE_TABLE_NAME
# SEED_AIRTABLE_EVENTS_API_KEY, SEED_AIRTABLE_EVENTS_BASE_ID, SEED_AIRTABLE_EVENTS_TABLE_NAME
preDeployCommand: python manage.py migrate && python manage.py createcachetable && python manage.py seed
preDeployCommand: >
python manage.py migrate &&
python manage.py createcachetable &&
unzip data/preview_env_seed.zip -d data &&
cat data/preview_env_seed.psql | python manage.py dbshell &&
python manage.py seed
healthCheckPath: /
buildFilter:
ignoredPaths:
Expand Down

0 comments on commit eea6166

Please sign in to comment.