From 47e38983bb13765aac13780b63c37b2e9d1d78a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gra=C3=B1a?= Date: Wed, 11 Dec 2024 11:32:16 -0300 Subject: [PATCH] More conditions based on source column for consul sql updates (#275) --- crates/corrosion/src/command/consul/sync.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/corrosion/src/command/consul/sync.rs b/crates/corrosion/src/command/consul/sync.rs index 669589ec..209c3d9b 100644 --- a/crates/corrosion/src/command/consul/sync.rs +++ b/crates/corrosion/src/command/consul/sync.rs @@ -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(), @@ -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(), @@ -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()], )); } @@ -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()], )); }