Manage the auto/manual flag in migrations_migrate

This commit is contained in:
Alexandre Aubin 2018-02-01 21:11:12 +01:00
parent c40f14e8f0
commit c568b04459
4 changed files with 18 additions and 4 deletions

View file

@ -1589,6 +1589,9 @@ tools:
help: skip the migration(s), use it only if you know what you are doing
full: --skip
action: store_true
--auto:
help: automatic mode, won't run manual migrations, use it only if you know what you are doing
action: store_true
### tools_migrations_state()

2
debian/postinst vendored
View file

@ -15,7 +15,7 @@ do_configure() {
yunohost service regen-conf --output-as none
echo "Launching migrations.."
yunohost tools migrations migrate
yunohost tools migrations migrate --auto
# restart yunohost-firewall if it's running
service yunohost-firewall status >/dev/null \

View file

@ -236,6 +236,7 @@
"migrations_show_currently_running_migration": "Running migration {number} {name}...",
"migrations_show_last_migration": "Last ran migration is {}",
"migrations_skip_migration": "Skipping migration {number} {name}...",
"migrations_to_be_ran_manually": "Migration {number} {name} has to be ran manually. Please go to Tools > Migrations on the webadmin, or run `yunohost tools migrations migrate`.",
"monitor_disabled": "The server monitoring has been disabled",
"monitor_enabled": "The server monitoring has been enabled",
"monitor_glances_con_failed": "Unable to connect to Glances server",

View file

@ -753,7 +753,7 @@ def tools_migrations_list():
return migrations
def tools_migrations_migrate(target=None, skip=False):
def tools_migrations_migrate(target=None, skip=False, auto=False):
"""
Perform migrations
"""
@ -816,8 +816,18 @@ def tools_migrations_migrate(target=None, skip=False):
# effectively run selected migrations
for migration in migrations:
if not skip:
logger.warn(m18n.n('migrations_show_currently_running_migration',
number=migration.number, name=migration.name))
# If we are migrating in "automatic mode" (i.e. from debian
# configure during an upgrade of the package) but the migration
# is to be ran manually by the user
if auto and migration.mode == "manual":
logger.warn(m18n.n('migrations_to_be_ran_manually',
number=migration.number, name=migration.name))
break
else:
logger.warn(m18n.n('migrations_show_currently_running_migration',
number=migration.number, name=migration.name))
try:
if mode == "forward":