feat: adds the setup command to the sqlx-cli

The reset command is the equivalent of `sqlx db create`,
and `sqlx migrate run`.
This commit is contained in:
Kramer Hampton
2020-08-31 18:00:18 -04:00
committed by Austin Bonander
parent 916f1fccf2
commit 2e1658e08b
3 changed files with 15 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
use crate::migrate;
use console::style;
use dialoguer::Confirm;
use sqlx::any::Any;
@@ -30,3 +31,13 @@ pub async fn drop(uri: &str, confirm: bool) -> anyhow::Result<()> {
Ok(())
}
pub async fn reset(uri: &str, confirm: bool) -> anyhow::Result<()> {
drop(uri, confirm).await?;
setup(uri).await
}
pub async fn setup(uri: &str) -> anyhow::Result<()> {
create(uri).await?;
migrate::run(uri).await
}