From 4f79f8c0d1af5daad68bca48c6e4fc5558fd7824 Mon Sep 17 00:00:00 2001 From: Gleb Novikov Date: Thu, 19 Dec 2024 18:33:23 +0000 Subject: [PATCH] WIP: fast-import: change postgres database to neondb --- compute_tools/src/bin/fast_import.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/compute_tools/src/bin/fast_import.rs b/compute_tools/src/bin/fast_import.rs index 793ec4cf1094..abd746e34433 100644 --- a/compute_tools/src/bin/fast_import.rs +++ b/compute_tools/src/bin/fast_import.rs @@ -189,12 +189,26 @@ pub(crate) async fn main() -> anyhow::Result<()> { format!("host=localhost port=5432 user={superuser} dbname=postgres"); loop { let res = tokio_postgres::connect(&restore_pg_connstring, tokio_postgres::NoTls).await; - if res.is_ok() { + if let Ok((client, connection)) = res { info!("postgres is ready, could connect to it"); + + tokio::spawn(async move { + if let Err(e) = connection.await { + eprintln!("connection error: {}", e); + } + }); + + client + .execute("CREATE DATABASE neondb", &[]) + .await + .context("create database neondb")?; + break; } } + let restore_pg_connstring = restore_pg_connstring.replace("dbname=postgres", "dbname=neondb"); + // // Decrypt connection string //