[cli] migrate up should apply all pending migrations (#1010)

This commit is contained in:
Billy Chan 2022-10-26 17:21:24 +08:00 committed by GitHub
parent f65340680a
commit cb76b8f443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 4 deletions

View File

@ -97,10 +97,9 @@ pub enum MigrateSubcommands {
value_parser,
short,
long,
default_value = "1",
help = "Number of pending migrations to apply"
)]
num: u32,
num: Option<u32>,
},
#[clap(value_parser, about = "Rollback applied migrations")]
Down {

View File

@ -29,7 +29,7 @@ pub fn run_migrate_command(
Some(MigrateSubcommands::Refresh) => ("refresh", migration_dir, None, verbose),
Some(MigrateSubcommands::Reset) => ("reset", migration_dir, None, verbose),
Some(MigrateSubcommands::Status) => ("status", migration_dir, None, verbose),
Some(MigrateSubcommands::Up { num }) => ("up", migration_dir, Some(num), verbose),
Some(MigrateSubcommands::Up { num }) => ("up", migration_dir, num, verbose),
Some(MigrateSubcommands::Down { num }) => {
("down", migration_dir, Some(num), verbose)
}

View File

@ -72,7 +72,7 @@ where
Some(MigrateSubcommands::Refresh) => M::refresh(db).await?,
Some(MigrateSubcommands::Reset) => M::reset(db).await?,
Some(MigrateSubcommands::Status) => M::status(db).await?,
Some(MigrateSubcommands::Up { num }) => M::up(db, Some(num)).await?,
Some(MigrateSubcommands::Up { num }) => M::up(db, num).await?,
Some(MigrateSubcommands::Down { num }) => M::down(db, Some(num)).await?,
Some(MigrateSubcommands::Init) => run_migrate_init(MIGRATION_DIR)?,
Some(MigrateSubcommands::Generate {