Skip to content

Commit

Permalink
store: remove entry from subgraph_features table when a subgraph is…
Browse files Browse the repository at this point in the history
… removed
  • Loading branch information
incrypto32 committed Aug 29, 2023
1 parent 837948a commit 5cc12fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions store/postgres/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,10 +1334,11 @@ impl<'a> Connection<'a> {
.map(|_| ())
}

/// Remove all subgraph versions and the entry in `deployment_schemas` for
/// subgraph `id` in a transaction
/// Remove all subgraph versions, the entry in `deployment_schemas` and the entry in
/// `subgraph_features` for subgraph `id` in a transaction
pub fn drop_site(&self, site: &Site) -> Result<(), StoreError> {
use deployment_schemas as ds;
use subgraph_features as f;
use subgraph_version as v;
use unused_deployments as u;

Expand All @@ -1355,6 +1356,9 @@ impl<'a> Connection<'a> {
if !exists {
delete(v::table.filter(v::deployment.eq(site.deployment.as_str())))
.execute(conn)?;

// Remove the entry in `subgraph_features`
delete(f::table.filter(f::id.eq(site.deployment.as_str()))).execute(conn)?;
}

update(u::table.filter(u::id.eq(site.id)))
Expand Down
5 changes: 4 additions & 1 deletion store/test-store/tests/postgres/subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,10 @@ fn subgraph_features() {
);
assert_eq!(1, data_source_kinds.len());

test_store::remove_subgraph(&id)
test_store::remove_subgraph(&id);
let features = get_subgraph_features(id.to_string());
// Subgraph was removed, so we expect the entry to be removed from `subgraph_features` table
assert!(features.is_none());
})
}

Expand Down

0 comments on commit 5cc12fc

Please sign in to comment.