Add threaded mt fetching, initial db tuff

This commit is contained in:
2026-08-14 18:58:22 +03:00
parent fbef11dfe7
commit c7d2af0fd0
11 changed files with 505 additions and 81 deletions

17
src/db/mod.rs Normal file
View 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
}