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 @ cargo clippy --all-targets -- -D warnings
.PHONY: lint .PHONY: lint
format:
@ cargo fmt
.PHONY: format
# =====DATABASE STUFF===== # =====DATABASE STUFF=====
db: db:

View File

@ -4,12 +4,8 @@ extern crate rocket;
#[macro_use] #[macro_use]
extern crate diesel_migrations; extern crate diesel_migrations;
use rocket_sync_db_pools::{diesel, database}; use rocket::{fairing::AdHoc, Build, Rocket};
use rocket::{ use rocket_sync_db_pools::{database, diesel};
Rocket,
Build,
fairing::AdHoc
};
embed_migrations!(); embed_migrations!();
@ -17,16 +13,22 @@ embed_migrations!();
struct HildeDbConn(diesel::PgConnection); struct HildeDbConn(diesel::PgConnection);
async fn run_db_migrations(rocket: Rocket<Build>) -> Result<Rocket<Build>, Rocket<Build>> { 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) { conn.run(|c| match embedded_migrations::run(c) {
Ok(()) => Ok(rocket), Ok(()) => Ok(rocket),
Err(_) => Err(rocket), Err(_) => Err(rocket),
}).await })
.await
} }
#[launch] #[launch]
fn rocket() -> _ { fn rocket() -> _ {
rocket::build() rocket::build()
.attach(HildeDbConn::fairing()) .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,
))
} }