Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM-1664 - Thirsty of better error management #207

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions mina-archive/scripts/db-bootstrap-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fetch_extra_sql_files() {

for URL in $URLS; do
info "Downloading $URL"
curl "$URL" -sO
curl "$URL" -sO --fail || { error "Unable to download the URL $URL"; return 1; }
done
}

Expand All @@ -128,14 +128,20 @@ run_sql_files() {

for URL in $URLS; do
info "Executing $URL"
curl --fail -s "$URL" -o download.sql || { error "Unable to download the URL $URL"; return 1; }
if [[ "$URL" == *.sql ]]; then
curl "$URL" -s | psql --set=ON_ERROR_STOP=1 -f -
psql --set=ON_ERROR_STOP=1 -f download.sql
elif [[ "$URL" == *.sql.tar.gz ]]; then
tmpdir=$(mktemp -d)
tar -xzvf download.sql -C "$tmpdir" || { error "Unable to untar the URL $URL"; return 1; }
if [[ $DB_BOOTSTRAP_CREATE_DATABASE == "true" ]]; then
curl "$URL" -s | tar -xz -O | psql --set=ON_ERROR_STOP=1 -f -
PSQL_DEFAULT_DB="$PGDATABASE"
else
curl "$URL" -s | tar -xz -O | psql postgres --set=ON_ERROR_STOP=1 -f -
PSQL_DEFAULT_DB="postgres"
fi
for file in "$tmpdir"/*; do
psql "$PSQL_DEFAULT_DB" --set=ON_ERROR_STOP=1 -f "$file"
done
else
error "URL extension not supported, error"
fi
Expand Down
1 change: 0 additions & 1 deletion mina-archive/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ dbBootstrap:
# -- SQL file urls to pre-download before executing the SQL file urls
extraSqlFileUrls: []
# - https://raw.githubusercontent.com/MinaProtocol/mina/develop/src/app/archive/zkapp_tables.sql
# - https://storage.googleapis.com/mina-archive-dumps

# -- Execute SQL inline command before loading the SQL file urls
# preCustomSql: SELECT session_user, current_database()
Expand Down
Loading