Add threaded mt fetching, initial db tuff
This commit is contained in:
17
src/db/mod.rs
Normal file
17
src/db/mod.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use diesel::pg::PgConnection;
|
||||
use diesel::prelude::*;
|
||||
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
|
||||
|
||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
|
||||
|
||||
pub fn init_db(database_url: &str) -> PgConnection {
|
||||
let mut connection = PgConnection::establish(database_url)
|
||||
.unwrap_or_else(|e| panic!("Error connecting to database: {e}"));
|
||||
|
||||
connection
|
||||
.run_pending_migrations(MIGRATIONS)
|
||||
.unwrap_or_else(|e| panic!("Error running migrations: {e}"));
|
||||
|
||||
connection
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user