Skip to content

Commit

Permalink
Add INDEX_NAME var to etl script and update acs.sql to use it to crea…
Browse files Browse the repository at this point in the history
…te geoid index
  • Loading branch information
TylerMatteo committed Feb 5, 2024
1 parent 468b93f commit 5837e98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion migrations/acs.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CREATE SCHEMA IF NOT EXISTS acs;
DROP TABLE IF EXISTS acs.:"TABLE_NAME";
DROP INDEX IF EXISTS acs.:INDEX_NAME;

CREATE TEMP TABLE tmp (
census_geoid text,
Expand Down Expand Up @@ -30,4 +31,4 @@ SELECT
z as percent_margin_of_error
INTO acs.:"TABLE_NAME" FROM tmp;

CREATE INDEX acs_:TABLE_NAME||_geoid_idx ON acs.:"TABLE_NAME" (geoid);
CREATE INDEX IF NOT EXISTS :INDEX_NAME ON acs.:"TABLE_NAME" (geoid);
2 changes: 1 addition & 1 deletion migrations/etl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if [[ $download -eq 1 ]]; then
fi

if [[ $load -eq 1 ]]; then
cat $filepath | psql $DATABASE_URL -v TABLE_NAME=$year -f migrations/$datasource.sql
cat $filepath | psql $DATABASE_URL -v TABLE_NAME=$year -v INDEX_NAME="${datasource}_${year}_geoid_idx" -f migrations/$datasource.sql
fi

if [[ $clean -eq 1 ]]; then
Expand Down

0 comments on commit 5837e98

Please sign in to comment.