:neocat_woozy: It works nyow
This commit is contained in:
parent
fd06408962
commit
180a4a7771
1 changed files with 4 additions and 13 deletions
|
@ -15,21 +15,12 @@ use std::error::Error;
|
|||
|
||||
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("migrations");
|
||||
|
||||
pub fn establish_connection(db_url: &str) -> PgConnection {
|
||||
pub fn establish_connection(db_url: &str) -> Result<PgConnection, Error> {
|
||||
//SqliteConnection::establish(db_url).unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e))
|
||||
let mut conn = PgConnection::establish(db_url)
|
||||
.unwrap_or_else(|e| panic!("Error connecting to {}: {}", db_url, e));
|
||||
// TODO: Add migrations here
|
||||
conn
|
||||
}
|
||||
|
||||
fn run_migrations_sqlite(connection: &mut impl MigrationHarness<Sqlite>) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
|
||||
|
||||
// This will run the necessary migrations.
|
||||
//
|
||||
// See the documentation for `MigrationHarness` for
|
||||
// all available methods.
|
||||
connection.run_pending_migrations(MIGRATIONS)?;
|
||||
|
||||
Ok(())
|
||||
let c: MigrationHarness<PgConnection> = &mut conn;
|
||||
c.run_pending_migrations(MIGRATIONS)?;
|
||||
Ok(conn)
|
||||
}
|
Loading…
Reference in a new issue