mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
feat: adds the reset command to the sqlx-cli
The reset command is the equivalent of `sqlx db drop`, `sqlx db create`, and `sqlx migrate run`. Unless the `-y` parameter is specified, it will prompt confirmation before dropping the database.
This commit is contained in:
committed by
Austin Bonander
parent
44594e2e03
commit
916f1fccf2
@@ -39,6 +39,11 @@ 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::drop(&database_url, yes).await?;
|
||||
database::create(&database_url).await?;
|
||||
migrate::run(&database_url).await?;
|
||||
}
|
||||
},
|
||||
|
||||
Command::Prepare { check: false, args } => prepare::run(&database_url, args)?,
|
||||
|
||||
@@ -57,6 +57,13 @@ 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,
|
||||
},
|
||||
}
|
||||
|
||||
/// Group of commands for creating and running migrations.
|
||||
|
||||
Reference in New Issue
Block a user