Skip to content

Commit 28da970

Browse files
committed
More conditions based on source column for consul sql updates
1 parent e66f039 commit 28da970

File tree

1 file changed

+6
-4
lines changed
  • crates/corrosion/src/command/consul

1 file changed

+6
-4
lines changed

crates/corrosion/src/command/consul/sync.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ fn append_upsert_service_statements(
412412
meta = excluded.meta,
413413
port = excluded.port,
414414
address = excluded.address,
415-
updated_at = excluded.updated_at;"
415+
updated_at = excluded.updated_at
416+
WHERE source IS NULL;"
416417
.into(),
417418
vec![
418419
node.into(),
@@ -457,7 +458,8 @@ fn append_upsert_check_statements(
457458
name = excluded.name,
458459
status = excluded.status,
459460
output = excluded.output,
460-
updated_at = excluded.updated_at;"
461+
updated_at = excluded.updated_at
462+
WHERE source IS NULL;"
461463
.into(),vec![
462464
node.into(),
463465
check.id.into(),
@@ -651,7 +653,7 @@ async fn execute(
651653
vec![id.clone().into()],
652654
));
653655
statements.push(Statement::WithParams(
654-
"DELETE FROM consul_services WHERE node = ? AND id = ?;".into(),
656+
"DELETE FROM consul_services WHERE node = ? AND id = ? AND source IS NULL;".into(),
655657
vec![node.into(), id.into()],
656658
));
657659
}
@@ -677,7 +679,7 @@ async fn execute(
677679
vec![id.clone().into()],
678680
));
679681
statements.push(Statement::WithParams(
680-
"DELETE FROM consul_checks WHERE node = ? AND id = ?;".into(),
682+
"DELETE FROM consul_checks WHERE node = ? AND id = ? AND source IS NULL;".into(),
681683
vec![node.into(), id.into()],
682684
));
683685
}

0 commit comments

Comments
 (0)