Skip to content

Commit

Permalink
fix: do not run the populate db script if db not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasianayden committed Mar 14, 2024
1 parent becbce9 commit 0d5797e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ckan/prepopulate_db/upload_vocabulary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@

set -e

psql postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$CKAN_DB -c "\copy public.term_translation FROM '/prepopulate_db/common_vocabulary_tags.csv' WITH (DELIMITER ',', FORMAT CSV, HEADER TRUE);"
psql postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:5432/$CKAN_DB <<-EOSQL
SELECT
EXISTS(SELECT 1 FROM public.term_translation) as table_not_empty
\gset
\if :table_not_empty
\echo 'term_translation table is not empty, skipping'
\else
\copy public.term_translation FROM '/prepopulate_db/common_vocabulary_tags.csv' WITH (DELIMITER ',', FORMAT CSV, HEADER TRUE);
\endif
EOSQL

0 comments on commit 0d5797e

Please sign in to comment.