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
|
@ cargo clippy --all-targets -- -D warnings
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
|
|
||||||
|
format:
|
||||||
|
@ cargo fmt
|
||||||
|
.PHONY: format
|
||||||
|
|
||||||
|
|
||||||
# =====DATABASE STUFF=====
|
# =====DATABASE STUFF=====
|
||||||
db:
|
db:
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -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,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue