From 00a83f4d91d564a81cc6df340140807a2110f8ef Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 14 Oct 2026 12:51:10 +0200 Subject: [PATCH] test: point the fork migrations test's DATABASE_URL at its own database (#11759) Co-authored-by: Claude Opus 5.5 --- backend/tests/datatable_fork_migrations.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/tests/datatable_fork_migrations.rs b/backend/tests/datatable_fork_migrations.rs index 43f43c1cd9..50f4d89705 100644 --- a/backend/tests/datatable_fork_migrations.rs +++ b/backend/tests/datatable_fork_migrations.rs @@ -22,6 +22,19 @@ fn authed(b: reqwest::RequestBuilder) -> reqwest::RequestBuilder { async fn a_forked_copy_keeps_its_applied_migrations(db: Pool) -> anyhow::Result<()> { initialize_tracing().await; let opts = (*db.connect_options()).clone(); + // The copy takes its settings locks on a connection of its own, opened from `DATABASE_URL` + // rather than the pool: point that at this test's database, not the one sqlx creates it from. + // Only this test runs in the binary, and before anything has read the variable. + let base_url = std::env::var("DATABASE_URL")?; + let (prefix, rest) = base_url + .rsplit_once('/') + .expect("DATABASE_URL names a database"); + let query = rest + .split_once('?') + .map(|(_, q)| format!("?{q}")) + .unwrap_or_default(); + let test_db = opts.get_database().expect("test database name"); + std::env::set_var("DATABASE_URL", format!("{prefix}/{test_db}{query}")); // Databases are cluster-wide, so both are named for this run alone. let suffix = format!( "{:x}",