pub async fn initialize_db(dsn: &str, schema_name: &str) {
    let mut init = DB_INITIALIZED.lock().await;

    // already done
    if init.contains(schema_name) {
        return;
    }

    info!("Initializing database...");

    // Create the catalog database if it doesn't exist
    if !Postgres::database_exists(dsn).await.unwrap() {
        info!("Creating database...");
        Postgres::create_database(dsn).await.unwrap();
    }

    // Set up the catalog
    Command::cargo_bin("influxdb_iox")
        .unwrap()
        .arg("catalog")
        .arg("setup")
        .env("INFLUXDB_IOX_CATALOG_DSN", dsn)
        .env("INFLUXDB_IOX_CATALOG_POSTGRES_SCHEMA_NAME", schema_name)
        .ok()
        .unwrap();

    // Create the shared Kafka topic in the catalog
    Command::cargo_bin("influxdb_iox")
        .unwrap()
        .arg("catalog")
        .arg("topic")
        .arg("update")
        .arg("iox-shared")
        .env("INFLUXDB_IOX_CATALOG_DSN", dsn)
        .env("INFLUXDB_IOX_CATALOG_POSTGRES_SCHEMA_NAME", schema_name)
        .ok()
        .unwrap();

    init.insert(schema_name.into());
}
/// Performs once-per-process database initialization, if necessary
Performs once-per-process database initialization, if necessary
Performs once - per - process database initialization if necessary
pub async fn initialize_db(dsn: &str, schema_name: &str) {
    let mut init = DB_INITIALIZED.lock().await;
    // already done
    if init.contains(schema_name) {
        return;
    }
    info!("Initializing database...");
    // Create the catalog database if it doesn't exist
    if !Postgres::database_exists(dsn).await.unwrap() {
        info!("Creating database...");
        Postgres::create_database(dsn).await.unwrap();
    }
    // Set up the catalog
    Command::cargo_bin("influxdb_iox")
        .unwrap()
        .arg("catalog")
        .arg("setup")
        .env("INFLUXDB_IOX_CATALOG_DSN", dsn)
        .env("INFLUXDB_IOX_CATALOG_POSTGRES_SCHEMA_NAME", schema_name)
        .ok()
        .unwrap();
    // Create the shared Kafka topic in the catalog
    Command::cargo_bin("influxdb_iox")
        .unwrap()
        .arg("catalog")
        .arg("topic")
        .arg("update")
        .arg("iox-shared")
        .env("INFLUXDB_IOX_CATALOG_DSN", dsn)
        .env("INFLUXDB_IOX_CATALOG_POSTGRES_SCHEMA_NAME", schema_name)
        .ok()
        .unwrap();
    init.insert(schema_name.into());
}
pub async fn initialize_db ( dsn : & str , schema_name : & str ) { let mut init = DB_INITIALIZED . lock ( ) . await ; // already done if init . contains ( schema_name ) { return ; } info ! ( " " ) ; // Create the catalog database if it doesn't exist if ! Postgres :: database_exists ( dsn ) . await . unwrap ( ) { info ! ( " " ) ; Postgres :: create_database ( dsn ) . await . unwrap ( ) ; } // Set up the catalog Command :: cargo_bin ( " " ) . unwrap ( ) . arg ( " " ) . arg ( " " ) . env ( " " , dsn ) . env ( " " , schema_name ) . ok ( ) . unwrap ( ) ; // Create the shared Kafka topic in the catalog Command :: cargo_bin ( " " ) . unwrap ( ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . arg ( " " ) . env ( " " , dsn ) . env ( " " , schema_name ) . ok ( ) . unwrap ( ) ; init . insert ( schema_name . into ( ) ) ; }
Performs once-per-process database initialization, if necessary
Performs once - per - process database initialization if necessary
dsn
&str
schema_name
&str
dsn
&str
schema_name
&str