Fixed linting errors
continuous-integration/drone the build was successful
Details
continuous-integration/drone the build was successful
Details
parent
424e723cd8
commit
de38073f71
4
Makefile
4
Makefile
|
@ -23,6 +23,10 @@ lint:
|
|||
@ cargo clippy --all-targets -- -D warnings
|
||||
.PHONY: lint
|
||||
|
||||
format:
|
||||
@ cargo fmt
|
||||
.PHONY: format
|
||||
|
||||
|
||||
# =====DATABASE STUFF=====
|
||||
db:
|
||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -4,12 +4,8 @@ extern crate rocket;
|
|||
#[macro_use]
|
||||
extern crate diesel_migrations;
|
||||
|
||||
use rocket_sync_db_pools::{diesel, database};
|
||||
use rocket::{
|
||||
Rocket,
|
||||
Build,
|
||||
fairing::AdHoc
|
||||
};
|
||||
use rocket::{fairing::AdHoc, Build, Rocket};
|
||||
use rocket_sync_db_pools::{database, diesel};
|
||||
|
||||
embed_migrations!();
|
||||
|
||||
|
@ -17,16 +13,22 @@ embed_migrations!();
|
|||
struct HildeDbConn(diesel::PgConnection);
|
||||
|
||||
async fn run_db_migrations(rocket: Rocket<Build>) -> Result<Rocket<Build>, Rocket<Build>> {
|
||||
let conn = HildeDbConn::get_one(&rocket).await.expect("database connection");
|
||||
let conn = HildeDbConn::get_one(&rocket)
|
||||
.await
|
||||
.expect("database connection");
|
||||
conn.run(|c| match embedded_migrations::run(c) {
|
||||
Ok(()) => Ok(rocket),
|
||||
Err(_) => Err(rocket),
|
||||
}).await
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build()
|
||||
.attach(HildeDbConn::fairing())
|
||||
.attach(AdHoc::try_on_ignite("Run database migrations", run_db_migrations))
|
||||
.attach(AdHoc::try_on_ignite(
|
||||
"Run database migrations",
|
||||
run_db_migrations,
|
||||
))
|
||||
}
|
||||
|
|
Reference in New Issue