diff --git a/swh/core/cli/db.py b/swh/core/cli/db.py --- a/swh/core/cli/db.py +++ b/swh/core/cli/db.py @@ -323,8 +323,13 @@ metavar="VERSION", default=None, ) +@click.option( + "--interactive/--non-interactive", + help="Do not ask questions (use default answer to all questions)", + default=True, +) @click.pass_context -def db_upgrade(ctx, module, to_version): +def db_upgrade(ctx, module, to_version, interactive): """Upgrade the database for given module (to a given version if specified). Examples:: @@ -360,7 +365,7 @@ fg="yellow", bold=True, ) - if not click.confirm( + if interactive and not click.confirm( f"Write the module information ({module}) in the database?", default=True ): raise click.BadParameter("Migration aborted.") diff --git a/swh/core/db/db_utils.py b/swh/core/db/db_utils.py --- a/swh/core/db/db_utils.py +++ b/swh/core/db/db_utils.py @@ -190,7 +190,7 @@ for sqlfile in sqlfiles: new_version = int(path.splitext(path.basename(sqlfile))[0]) - logger.info("Executing migration script {sqlfile}") + logger.info("Executing migration script '%s'", sqlfile) if db_version is not None and (new_version - db_version) > 1: logger.error( f"There are missing migration steps between {db_version} and "