Fixed linting errors
continuous-integration/drone the build was successful Details

pull/11/head
Jef Roosens 2021-06-27 15:00:55 +02:00
parent 424e723cd8
commit de38073f71
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
2 changed files with 15 additions and 9 deletions

View File

@ -23,6 +23,10 @@ lint:
@ cargo clippy --all-targets -- -D warnings
.PHONY: lint
format:
@ cargo fmt
.PHONY: format
# =====DATABASE STUFF=====
db:

View File

@ -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,
))
}