Skip to content

Commit

Permalink
More conditions based on source column for consul sql updates (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangra authored Dec 11, 2024
1 parent e66f039 commit 47e3898
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/corrosion/src/command/consul/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ fn append_upsert_service_statements(
meta = excluded.meta,
port = excluded.port,
address = excluded.address,
updated_at = excluded.updated_at;"
updated_at = excluded.updated_at
WHERE source IS NULL;"
.into(),
vec![
node.into(),
Expand Down Expand Up @@ -457,7 +458,8 @@ fn append_upsert_check_statements(
name = excluded.name,
status = excluded.status,
output = excluded.output,
updated_at = excluded.updated_at;"
updated_at = excluded.updated_at
WHERE source IS NULL;"
.into(),vec![
node.into(),
check.id.into(),
Expand Down Expand Up @@ -651,7 +653,7 @@ async fn execute(
vec![id.clone().into()],
));
statements.push(Statement::WithParams(
"DELETE FROM consul_services WHERE node = ? AND id = ?;".into(),
"DELETE FROM consul_services WHERE node = ? AND id = ? AND source IS NULL;".into(),
vec![node.into(), id.into()],
));
}
Expand All @@ -677,7 +679,7 @@ async fn execute(
vec![id.clone().into()],
));
statements.push(Statement::WithParams(
"DELETE FROM consul_checks WHERE node = ? AND id = ?;".into(),
"DELETE FROM consul_checks WHERE node = ? AND id = ? AND source IS NULL;".into(),
vec![node.into(), id.into()],
));
}
Expand Down

0 comments on commit 47e3898

Please sign in to comment.