mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
fix: usage of migrate::run now takes two parameters
This commit is contained in:
parent
1ed75ba5f0
commit
12da5ba534
3 changed files with 19 additions and 7 deletions
|
@ -33,12 +33,12 @@ pub async fn drop(uri: &str, confirm: bool) -> anyhow::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn reset(uri: &str, confirm: bool) -> anyhow::Result<()> {
|
||||
pub async fn reset(migration_source: &str, uri: &str, confirm: bool) -> anyhow::Result<()> {
|
||||
drop(uri, confirm).await?;
|
||||
setup(uri).await
|
||||
setup(migration_source, uri).await
|
||||
}
|
||||
|
||||
pub async fn setup(uri: &str) -> anyhow::Result<()> {
|
||||
pub async fn setup(migration_source: &str, uri: &str) -> anyhow::Result<()> {
|
||||
create(uri).await?;
|
||||
migrate::run(uri).await
|
||||
migrate::run(migration_source, uri).await
|
||||
}
|
||||
|
|
|
@ -39,8 +39,10 @@ hint: This command only works in the manifest directory of a Cargo package."#
|
|||
Command::Database(database) => match database.command {
|
||||
DatabaseCommand::Create => database::create(&database_url).await?,
|
||||
DatabaseCommand::Drop { yes } => database::drop(&database_url, !yes).await?,
|
||||
DatabaseCommand::Reset { yes } => database::reset(&database_url, yes).await?,
|
||||
DatabaseCommand::Setup => database::setup(&database_url).await?,
|
||||
DatabaseCommand::Reset { yes, source } => {
|
||||
database::reset(&source, &database_url, yes).await?
|
||||
}
|
||||
DatabaseCommand::Setup { source } => database::setup(&source, &database_url).await?,
|
||||
},
|
||||
|
||||
Command::Prepare { check: false, args } => prepare::run(&database_url, args)?,
|
||||
|
|
|
@ -57,15 +57,25 @@ pub enum DatabaseCommand {
|
|||
#[clap(short)]
|
||||
yes: bool,
|
||||
},
|
||||
|
||||
/// Drops the database specified in your DATABASE_URL, re-creates it, and runs any pending migrations.
|
||||
Reset {
|
||||
/// Automatic confirmation. Without this option, you will be prompted before dropping
|
||||
/// your database.
|
||||
#[clap(short)]
|
||||
yes: bool,
|
||||
|
||||
/// Path to folder containing migrations. Defaults to 'migrations'
|
||||
#[clap(long, default_value = "migrations")]
|
||||
source: String,
|
||||
},
|
||||
|
||||
/// Creates the database specified in your DATABASE_URL and runs any pending migrations.
|
||||
Setup,
|
||||
Setup {
|
||||
/// Path to folder containing migrations. Defaults to 'migrations'
|
||||
#[clap(long, default_value = "migrations")]
|
||||
source: String,
|
||||
},
|
||||
}
|
||||
|
||||
/// Group of commands for creating and running migrations.
|
||||
|
|
Loading…
Reference in a new issue