Skip to content

Commit

Permalink
refactor: normalize schemaNNN and db owner before publishing snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed May 3, 2024
1 parent a7c8ccc commit 5152572
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit 5152572

Please sign in to comment.