-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit concurrent tests and fix dbmate function (#28)
- Loading branch information
1 parent
93bb8dd
commit 135e493
Showing
3 changed files
with
21 additions
and
12 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,17 +1,26 @@ | ||
use std::process::Command; | ||
|
||
pub fn dbmate_up(url: &str) { | ||
log::info!("dbmate up DATABASE_URL: {}", url); | ||
let do_steps = || -> bool { | ||
Command::new("sh") | ||
.arg("-c") | ||
.arg("dbmate up") | ||
pub fn dbmate_rebuild(url: &str) { | ||
let do_steps = || -> anyhow::Result<()> { | ||
Command::new("dbmate") | ||
.arg("drop") | ||
.env("DATABASE_URL", &url) | ||
.status() | ||
.expect("failed to execute process"); | ||
Command::new("dbmate") | ||
.arg("up") | ||
.env("DATABASE_URL", &url) | ||
.status() | ||
.expect("failed to execute process"); | ||
Command::new("dbmate") | ||
.arg("wait") | ||
.env("DATABASE_URL", url) | ||
.status() | ||
.expect("failed to execute process") | ||
.success() | ||
.expect("failed to execute process"); | ||
Ok(()) | ||
}; | ||
if !do_steps() { | ||
panic!("Failed to perform dbmate up operation"); | ||
if let Err(err) = do_steps() { | ||
println!("Failed to perform db operation {}", err.to_string()); | ||
dbmate_rebuild(url); | ||
} | ||
} |
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