From 3f10f74f04c29ca6792971bb4d06e7fee0a21cfd Mon Sep 17 00:00:00 2001 From: MasterPtato <23087326+MasterPtato@users.noreply.github.com> Date: Wed, 23 Oct 2024 08:29:27 +0000 Subject: [PATCH] fix(pegboard): fix migrations (#1230) ## Changes --- lib/migrate/src/migrate.rs | 8 +++++--- ...flavor.down.sql => 20241011221018_add_flavor.down.sql} | 0 ...add_flavor.up.sql => 20241011221018_add_flavor.up.sql} | 0 svc/pkg/pegboard/src/protocol.rs | 1 + svc/pkg/pegboard/standalone/ws/src/lib.rs | 6 ++---- 5 files changed, 8 insertions(+), 7 deletions(-) rename svc/pkg/pegboard/db/pegboard/migrations/{1729276557065_add_flavor.down.sql => 20241011221018_add_flavor.down.sql} (100%) rename svc/pkg/pegboard/db/pegboard/migrations/{1729276557065_add_flavor.up.sql => 20241011221018_add_flavor.up.sql} (100%) diff --git a/lib/migrate/src/migrate.rs b/lib/migrate/src/migrate.rs index 13e15c9763..cdc0744e3f 100644 --- a/lib/migrate/src/migrate.rs +++ b/lib/migrate/src/migrate.rs @@ -157,9 +157,10 @@ 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(()) @@ -167,8 +168,9 @@ pub async fn up(services: &[SqlService]) -> Result<()> { 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}"))?; } } diff --git a/svc/pkg/pegboard/db/pegboard/migrations/1729276557065_add_flavor.down.sql b/svc/pkg/pegboard/db/pegboard/migrations/20241011221018_add_flavor.down.sql similarity index 100% rename from svc/pkg/pegboard/db/pegboard/migrations/1729276557065_add_flavor.down.sql rename to svc/pkg/pegboard/db/pegboard/migrations/20241011221018_add_flavor.down.sql diff --git a/svc/pkg/pegboard/db/pegboard/migrations/1729276557065_add_flavor.up.sql b/svc/pkg/pegboard/db/pegboard/migrations/20241011221018_add_flavor.up.sql similarity index 100% rename from svc/pkg/pegboard/db/pegboard/migrations/1729276557065_add_flavor.up.sql rename to svc/pkg/pegboard/db/pegboard/migrations/20241011221018_add_flavor.up.sql diff --git a/svc/pkg/pegboard/src/protocol.rs b/svc/pkg/pegboard/src/protocol.rs index e1e7ed85d4..bb67f98e46 100644 --- a/svc/pkg/pegboard/src/protocol.rs +++ b/svc/pkg/pegboard/src/protocol.rs @@ -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, diff --git a/svc/pkg/pegboard/standalone/ws/src/lib.rs b/svc/pkg/pegboard/standalone/ws/src/lib.rs index 39b67adf26..3324294e00 100644 --- a/svc/pkg/pegboard/standalone/ws/src/lib.rs +++ b/svc/pkg/pegboard/standalone/ws/src/lib.rs @@ -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:?}"), } } @@ -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"), } }