this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 3a1ce8e0e4e1e2a5a69cb057d8debe3a19c8dad9 21 lines 556 B view raw
1//! create a connection pool and setup tables before making avaliable 2 3use std::sync::Arc; 4 5use crate::config; 6use sqlx::{Pool, Postgres, migrate, postgres::PgPool}; 7 8pub async fn conn() -> Arc<Pool<Postgres>> { 9 let conn = match PgPool::connect(&config::DATABASE_URL).await { 10 Ok(val) => val, 11 Err(err) => { 12 panic!("Could not connect to the database. Got error {err}"); 13 } 14 }; 15 16 migrate!().run(&conn).await.unwrap_or_else(|err| { 17 panic!("Error running migrations: {}", err); 18 }); 19 20 Arc::new(conn) 21}