Skip to content

Commit

Permalink
fix(pegboard): fix migrations (#1230)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Oct 23, 2024
1 parent 75bb7e2 commit 3f10f74
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
8 changes: 5 additions & 3 deletions lib/migrate/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,20 @@ pub async fn up(services: &[SqlService]) -> Result<()> {
tokio::try_join!(
async {
if !crdb_pre_queries.is_empty() {
let mut conn = crdb.acquire().await.context("can't acquire crdb")?;

for query in crdb_pre_queries {
let mut conn = crdb.acquire().await?;
conn.execute(query.as_str()).await?;
conn.execute(query.as_str()).await.with_context(|| format!("failed executing crdb pre-migration:\n{query}"))?;
}
}
Ok(())
},
async {
if !clickhouse_pre_queries.is_empty() {
let clickhouse = clickhouse.as_ref().context("missing clickhouse")?;

for query in clickhouse_pre_queries {
clickhouse.query(&query).execute().await?;
clickhouse.query(&query).execute().await.with_context(|| format!("failed executing clickhouse pre-migration:\n{query}"))?;
}
}

Expand Down
1 change: 1 addition & 0 deletions svc/pkg/pegboard/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl ToClient {

#[signal("pegboard_forward_to_server")]
#[serde(rename_all = "snake_case")]
#[derive(Debug)]
pub enum ToServer {
Init {
last_command_idx: i64,
Expand Down
6 changes: 2 additions & 4 deletions svc/pkg/pegboard/standalone/ws/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async fn handle_connection_inner(
Message::Close(_) => {
bail!("socket closed {client_id}");
}
_ => bail!("unexpected initial message: {msg:?}"),
msg => bail!("unexpected initial message: {msg:?}"),
}
}

Expand All @@ -207,9 +207,7 @@ async fn handle_connection_inner(
Message::Close(_) => {
bail!("socket closed {client_id}");
}
msg => {
tracing::warn!(?client_id, ?msg, "unexpected message");
}
msg => tracing::warn!(?client_id, ?msg, "unexpected message"),
}
}

Expand Down

0 comments on commit 3f10f74

Please sign in to comment.