Skip to content

Commit

Permalink
Fix view output
Browse files Browse the repository at this point in the history
Update CHANGELOG
  • Loading branch information
mcarans committed Apr 30, 2024
1 parent 3181fd5 commit f26ff7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [0.7.8] - 2024-05-01

### Added

- Output views

## [0.7.7] - 2024-04-09

### Removed
Expand Down
16 changes: 8 additions & 8 deletions dump_views.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ echo "Started at $now"

mkdir -p database/csv

tables=$(docker exec -t postgres-container psql -t -U postgres -d hapi -c \
views=$(docker exec -t postgres-container psql -t -U postgres -d hapi -c \
"select table_name from INFORMATION_SCHEMA.views WHERE table_schema = ANY (current_schemas(false))")

for table in $tables
for view in $views
do
table=${table::-1}
if [[ -z "$table" ]]; then
view=${view::-1}
if [[ -z "$view" ]]; then
continue
fi

echo "Saving $table"
echo "Saving $view"

docker exec -t postgres-container psql -U postgres -d hapi -c \
"\copy (select * from ${table}_view) TO STDOUT (FORMAT csv, DELIMITER ',', HEADER);" \
"\copy (select * from ${view}) TO STDOUT (FORMAT csv, DELIMITER ',', HEADER);" \
| tee \
>(gzip > database/csv/${table}.csv.gz) \
>(md5sum | awk '{print $1}' > database/csv/${table}.hash) \
>(gzip > database/csv/${view}.csv.gz) \
>(md5sum | awk '{print $1}' > database/csv/${view}.hash) \
>/dev/null
done

Expand Down

0 comments on commit f26ff7f

Please sign in to comment.