Skip to content

Commit

Permalink
feat: allow skipping insertion of historical/test data in migrations …
Browse files Browse the repository at this point in the history
…container
  • Loading branch information
jmgilman committed Jul 25, 2023
1 parent 866eceb commit f0d2f90
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions containers/event-db-migrations/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
# DB_SUPERUSER_PASSWORD - The password of the database superuser
# DB_USER - The username of the database user
# DB_USER_PASSWORD - The password of the database user
# DB_SKIP_HISTORICAL_DATA - If set, historical data will not be added to the database (optional)
# DB_SKIP_TEST_DATA - If set, test data will not be added to the database (optional)
# ADMIN_ROLE_PASSWORD - The password of the cat_admin role for graphql
# ADMIN_USER_PASSWORD - The password of the admin user for graphql
# ANON_ROLE_PASSWORD - The password of the cat_anon role for graphql
Expand Down Expand Up @@ -135,15 +137,20 @@ echo ">>> Running migrations..."
export DATABASE_URL="postgres://${DB_USER}:${DB_USER_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
./refinery migrate -e DATABASE_URL -c ./refinery.toml -p ./migrations

# Add historic data from previous funds
while IFS= read -r -d '' file; do
echo "Adding historic data from $file"
psql -f "$file"
done < <(find ./historic_data -name '*.sql' -print0 | sort -z)
# Add historical data from previous funds
if [[ -z "${DB_SKIP_HISTORICAL_DATA:-}" ]]; then
while IFS= read -r -d '' file; do
echo "Adding historic data from $file"
psql -f "$file"
done < <(find ./historic_data -name '*.sql' -print0 | sort -z)
fi

# Add test data
while IFS= read -r -d '' file; do
echo "Adding test data from $file"
psql -f "$file"
done < <(find ./test_data -name '*.sql' -print0 | sort -z)
if [[ -z "${DB_SKIP_TEST_DATA:-}" ]]; then
while IFS= read -r -d '' file; do
echo "Adding test data from $file"
psql -f "$file"
done < <(find ./test_data -name '*.sql' -print0 | sort -z)
fi

echo ">>> Finished entrypoint script"

0 comments on commit f0d2f90

Please sign in to comment.