Skip to content

Commit 7c8c6d7

Browse files
authored
Merge pull request #8674 from cfpb/fix/refresh-data
Database script updates to support containerization
2 parents 5b2f3d7 + 45a39ef commit 7c8c6d7

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

docker-entrypoint.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ if [ ! -z "$RUN_MIGRATIONS" ]; then
2323
if [ -n "$CFGOV_PROD_DB_LOCATION" ] || [ -n "$DB_DUMP_FILE" ] || [ -n "$DB_DUMP_URL" ]; then
2424
echo "Running refresh-data.sh... $DB_DUMP_FILE"
2525
./refresh-data.sh "$DB_DUMP_FILE"
26-
echo "Create the cache table..."
27-
./cfgov/manage.py createcachetable
2826

2927
# refresh-data.sh runs migrations and rebuilds index,
3028
# unset vars to prevent further action

initial-data.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set -e
1212
# Import Data
1313
import_data(){
1414
echo 'Running Django migrations...'
15-
./cfgov/manage.py migrate
15+
./cfgov/manage.py migrate --noinput
1616
echo 'Creating any necessary Django database cache tables...'
1717
./cfgov/manage.py createcachetable
1818
echo 'Running initial_data script to configure Wagtail admin...'

refresh-data.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,14 @@ check_data() {
5555
refresh_data() {
5656
echo 'Importing refresh db'
5757
gunzip < "$refresh_dump_name" | cfgov/manage.py dbshell > /dev/null
58-
SCHEMA="$(gunzip -c $refresh_dump_name | grep -m 1 'CREATE SCHEMA' | sed 's/CREATE SCHEMA \(.*\);$/\1/')"
59-
PGUSER="${PGUSER:-cfpb}"
60-
if [ "${PGUSER}" != "${SCHEMA}" ]; then
61-
echo "Adjusting schema name to match username..."
62-
echo "DROP SCHEMA IF EXISTS \"${PGUSER}\" CASCADE; \
63-
ALTER SCHEMA \"${SCHEMA}\" RENAME TO \"${PGUSER}\"" | psql > /dev/null 2>&1
64-
fi
65-
echo 'Running any necessary migrations'
66-
./cfgov/manage.py migrate --noinput --fake-initial
67-
echo 'Setting up initial data'
68-
./cfgov/manage.py runscript initial_data
58+
}
59+
60+
initial_data() {
61+
./initial-data.sh
6962
}
7063

7164
update_index() {
72-
source ./index.sh
65+
source ./index.sh
7366
}
7467

7568
get_data() {
@@ -108,6 +101,7 @@ done
108101
get_data
109102
check_data
110103
refresh_data
104+
initial_data
111105

112106
if [[ $noindex -ne 1 ]]; then
113107
update_index

0 commit comments

Comments
 (0)