From c568b04459422bea7d0e8a92a2b33bbfedec7ac3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 1 Feb 2018 21:11:12 +0100 Subject: [PATCH] Manage the auto/manual flag in migrations_migrate --- data/actionsmap/yunohost.yml | 3 +++ debian/postinst | 2 +- locales/en.json | 1 + src/yunohost/tools.py | 16 +++++++++++++--- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 77887b41a..d84d308c0 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -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() diff --git a/debian/postinst b/debian/postinst index 7e91ffbb3..5b6ed8259 100644 --- a/debian/postinst +++ b/debian/postinst @@ -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 \ diff --git a/locales/en.json b/locales/en.json index 4828c6f2a..7597e17e4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -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", diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index 1e49d1f00..0e2e1195c 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -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":