claude rework
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
use diesel::pg::PgConnection;
|
||||
use diesel::prelude::*;
|
||||
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
|
||||
use dotenv::dotenv;
|
||||
use std::env;
|
||||
|
||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
|
||||
|
||||
pub fn establish_connection() -> PgConnection {
|
||||
dotenv().ok();
|
||||
|
||||
@@ -10,3 +13,9 @@ pub fn establish_connection() -> PgConnection {
|
||||
PgConnection::establish(&database_url)
|
||||
.unwrap_or_else(|e| panic!("Error connecting to database {}: {}", database_url, e))
|
||||
}
|
||||
|
||||
pub fn run_migrations(connection: &mut PgConnection) {
|
||||
connection
|
||||
.run_pending_migrations(MIGRATIONS)
|
||||
.expect("Failed to run database migrations");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user