core: Keep SubgraphDeployment if deploying same subgraph hash
@@ -462,7 +462,7 @@ fn create_subgraph_version(
);
}
- // If currentVersion is actually being changed
+ // If currentVersion is actually being changed, an old deployment may need to be removed.
if current_version_id_opt != Some(manifest.id.to_string()) {
// If there is a previous version that will no longer be "current"
if let Some(current_version_id) = current_version_id_opt {
@@ -480,6 +480,8 @@ fn create_subgraph_version(
.as_string()
.unwrap();
+ // If old current and new current versions have same hash, no need to remove deployment
+ if previous_version_hash != manifest.id.to_string() {
// Find all subgraph versions that point to this hash
let referencing_version_entities =
store.find(SubgraphVersionEntity::query().filter(EntityFilter::Equal(
@@ -517,6 +519,7 @@ fn create_subgraph_version(
}
}
}
+ }
// Check if deployment already exists for this hash
let deployment_entity_opt = store.get(SubgraphDeploymentEntity::key(manifest.id.clone()))?;
