-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from freifunk-saar/refactor
a bit of refactoring
- Loading branch information
Showing
10 changed files
with
308 additions
and
328 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use diesel_migrations::MigrationHarness; | ||
|
||
use rocket::fairing::{AdHoc, Fairing}; | ||
use rocket_sync_db_pools::{database, diesel}; | ||
|
||
// DB connection guard type | ||
#[database("postgres")] | ||
pub struct DbConn(diesel::PgConnection); | ||
|
||
pub fn migration() -> impl Fairing { | ||
AdHoc::on_ignite("Run DB migrations", move |rocket| async move { | ||
let migrations = diesel_migrations::FileBasedMigrations::find_migrations_directory() | ||
.expect("could not load migrations"); | ||
let conn = DbConn::get_one(&rocket) | ||
.await | ||
.expect("could not connect to DB for migrations"); | ||
conn.run(move |db| { | ||
db.run_pending_migrations(migrations).unwrap(); | ||
}) | ||
.await; | ||
rocket | ||
}) | ||
} |
Oops, something went wrong.