async fn create_postgres_admin_conn(mut url: Url) -> ConnectorResult<Connection> {
    let candidate_default_databases = &["postgres", "template1"];

    let mut conn = None;

    for database_name in candidate_default_databases {
        url.set_path(&format!("/{}", database_name));
        match connect(url.as_str()).await {
            // If the database does not exist, try the next one.
            Err(err) => match &err.error_code() {
                Some(DatabaseDoesNotExist::ERROR_CODE) => (),
                _ => {
                    conn = Some(Err(err));
                    break;
                }
            },
            // If the outcome is anything else, use this.
            other_outcome => {
                conn = Some(other_outcome);
                break;
            }
        }
    }

    let conn = conn.ok_or_else(|| {
        ConnectorError::user_facing_error(migration_engine::DatabaseCreationFailed { database_error: "Prisma could not connect to a default database (`postgres` or `template1`), it cannot create the specified database.".to_owned() })
    })??;

    Ok(conn)
}
/// Try to connect as an admin to a postgres database. We try to pick a default database from which
/// we can create another database.
Try to connect as an admin to a postgres database. We try to pick a default database from which
we can create another database.
Try to connect as an admin to a postgres database . We try to pick a default database from which we can create another database .
async fn create_postgres_admin_conn(mut url: Url) -> ConnectorResult<Connection> {
    let candidate_default_databases = &["postgres", "template1"];
    let mut conn = None;
    for database_name in candidate_default_databases {
        url.set_path(&format!("/{}", database_name));
        match connect(url.as_str()).await {
            // If the database does not exist, try the next one.
            Err(err) => match &err.error_code() {
                Some(DatabaseDoesNotExist::ERROR_CODE) => (),
                _ => {
                    conn = Some(Err(err));
                    break;
                }
            },
            // If the outcome is anything else, use this.
            other_outcome => {
                conn = Some(other_outcome);
                break;
            }
        }
    }
    let conn = conn.ok_or_else(|| {
        ConnectorError::user_facing_error(migration_engine::DatabaseCreationFailed { database_error: "Prisma could not connect to a default database (`postgres` or `template1`), it cannot create the specified database.".to_owned() })
    })??;
    Ok(conn)
}
async fn create_postgres_admin_conn ( mut url : Url ) -> ConnectorResult < Connection > { let candidate_default_databases = & [ " " , " " ] ; let mut conn = None ; for database_name in candidate_default_databases { url . set_path ( & format ! ( " " database_name ) ) ; match connect ( url . as_str ( ) ) . await { // If the database does not exist, try the next one. Err ( err ) => match & err . error_code ( ) { Some ( DatabaseDoesNotExist :: ERROR_CODE ) => ( ) , _ => { conn = Some ( Err ( err ) ) ; break ; } } , // If the outcome is anything else, use this. other_outcome => { conn = Some ( other_outcome ) ; break ; } } } let conn = conn . ok_or_else ( | | { ConnectorError :: user_facing_error ( migration_engine :: DatabaseCreationFailed { database_error : " " . to_owned ( ) } ) } ) ? ? ; Ok ( conn ) }
Try to connect as an admin to a postgres database.
Try to connect as an admin to a postgres database .
url
Url
url
Url