Skip to content

Commit

Permalink
Update the other queries to consider source column
Browse files Browse the repository at this point in the history
  • Loading branch information
dangra committed Nov 19, 2024
1 parent c3b76a1 commit afe2453
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/corrosion/src/command/consul/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ async fn setup(corrosion: &CorrosionClient) -> eyre::Result<()> {
("meta", vec![ColumnType::Text, ColumnType::Blob]),
("port", vec![ColumnType::Integer]),
("address", vec![ColumnType::Text]),
("source", vec![ColumnType::Text]),
("updated_at", vec![ColumnType::Integer]),
];

Expand Down Expand Up @@ -203,6 +204,7 @@ async fn setup(corrosion: &CorrosionClient) -> eyre::Result<()> {
("name", vec![ColumnType::Text]),
("status", vec![ColumnType::Text]),
("output", vec![ColumnType::Text]),
("source", vec![ColumnType::Text]),
("updated_at", vec![ColumnType::Integer]),
];

Expand Down Expand Up @@ -412,7 +414,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 +460,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 +655,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 +681,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 afe2453

Please sign in to comment.