From 21b9ea181c6b7992de4658e4db93aef6457f7522 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 9 Oct 2026 20:18:07 +0200 Subject: [PATCH] fix: record the python baseline on the migration connection Co-Authored-By: Claude Opus 5.5 --- backend/windmill-api/src/db.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/windmill-api/src/db.rs b/backend/windmill-api/src/db.rs index 158302436e..1b4d6e2bc7 100644 --- a/backend/windmill-api/src/db.rs +++ b/backend/windmill-api/src/db.rs @@ -380,7 +380,8 @@ pub async fn migrate( } crate::live_migrations::custom_migrations(&mut custom_migrator).await?; - if let Err(e) = seed_instance_python_baseline(db, new_instance).await { + if let Err(e) = seed_instance_python_baseline(custom_migrator.connection(), new_instance).await + { tracing::error!("Could not record the instance python baseline: {e:#}"); } Ok(Some(crate::live_migrations::spawn_background_migrations( @@ -393,7 +394,12 @@ pub async fn migrate( /// is unset. Only the process that created the schema knows the instance is new, so its value /// replaces whatever a server that started alongside it recorded; every other start leaves an /// existing record alone and gives an instance that predates the record the frozen default. -async fn seed_instance_python_baseline(db: &DB, new_instance: bool) -> Result<(), Error> { +/// +/// Runs on the migration connection: a `DATABASE_CONNECTIONS=1` pool has no second one to give. +async fn seed_instance_python_baseline( + conn: &mut PgConnection, + new_instance: bool, +) -> Result<(), Error> { let (version, on_conflict) = if new_instance { ( PyVAlias::NEW_INSTANCE, @@ -408,7 +414,7 @@ async fn seed_instance_python_baseline(db: &DB, new_instance: bool) -> Result<() )) .bind(INSTANCE_PYTHON_BASELINE_SETTING) .bind(version.version_string()) - .execute(db) + .execute(conn) .await?; Ok(()) }