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

snapshot scripts - normalize values before publishing #85

Merged
merged 1 commit into from
May 6, 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
2 changes: 1 addition & 1 deletion scripts/load_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ echo "ID: ${schema_id}"
echo "sgdNNN: ${sgdNNN}"

# Customize the snapshot file to use the identifier assigned locally; and modifies the owner
sed -i "s/sgd[0-9]*/${sgdNNN}/g" ${SNAPSHOT_FILE}
sed -i "s/sgd\([0-9]\+\|NNN\)/${sgdNNN}/g" ${SNAPSHOT_FILE}
sed -i "s/OWNER TO [^;]*;/OWNER TO ${DB_USER};/g" ${SNAPSHOT_FILE}

# Drop local schema and load in remote
Expand Down
3 changes: 3 additions & 0 deletions scripts/take_snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ FILE_NAME="snapshot_${IPFS_HASH}.sql"
SNAPSHOT_ACTION=$(PGPASSWORD=$DB_PSWD pg_dump -h $DB_HOST -U $DB_USER -d $DB_NAME -n $sgdNNN > ${SERVER_STORE}/${FILE_NAME})
echo "Action result: ${SNAPSHOT_ACTION}"
echo "Snapshot created: ${FILE_NAME}"
# Normalize the snapshot file to use placeholder identifier and owner
sed -i -E "s/sgd[0-9]+/sgdNNN/g" ${SERVER_STORE}/${FILE_NAME}
sed -i "s/OWNER TO [^;]*;/OWNER TO graphuser;/g" ${SERVER_STORE}/${FILE_NAME}

# Query metadata data
METADATA_QUERY="SELECT deployment, failed, synced, latest_ethereum_block_hash, latest_ethereum_block_number, entity_count, graft_base, graft_block_hash, graft_block_number, fatal_error, non_fatal_errors, health, reorg_count, current_reorg_depth, max_reorg_depth, last_healthy_ethereum_block_hash, last_healthy_ethereum_block_number, id, firehose_cursor, debug_fork, earliest_block_number FROM subgraphs.subgraph_deployment WHERE deployment = '${IPFS_HASH}';"
Expand Down
Loading