diff --git a/bench/cli.py b/bench/cli.py index a64f0687..6b3bcec2 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -201,7 +201,9 @@ def migrate_3to4(path): @click.command('migrate-to-v5') def _migrate_to_v5(bench='.'): "Migrate to Version 5" - migrate_to_v5(bench=bench) + click.echo("This will migrate all sites in the bench to version 5.") + if click.confirm("This is irreversible. Do you want to continue?", abort=True): + migrate_to_v5(bench=bench) @click.command('set-nginx-port') @click.argument('site') diff --git a/bench/migrate_to_v5.py b/bench/migrate_to_v5.py index 19fee216..0b4d1e22 100644 --- a/bench/migrate_to_v5.py +++ b/bench/migrate_to_v5.py @@ -3,6 +3,7 @@ from .release import get_current_version from .app import remove_from_appstxt import os import shutil +import sys repos = ('frappe', 'erpnext') @@ -12,19 +13,14 @@ def migrate_to_v5(bench='.'): for repo in repos: checkout_v5(repo, bench=bench) remove_shopping_cart(bench=bench) - restart_update({ - 'patch': True, - 'build': True, - 'requirements': True, - 'restart-supervisor': True - }) + exec_cmd("{bench} update".format(bench=sys.argv[0])) def remove_shopping_cart(bench='.'): - exec_cmd("{pip} --no-input uninstall -y shopping_cart".format(pip=os.path.join(bench, 'env', 'bin', 'pip'))) exec_cmd("{frappe} all --remove_from_installed_apps shopping_cart".format( frappe=get_frappe(bench=bench)), cwd=os.path.join(bench, 'sites')) remove_from_appstxt('shopping_cart', bench=bench) + exec_cmd("{pip} --no-input uninstall -y shopping_cart".format(pip=os.path.join(bench, 'env', 'bin', 'pip'))) archived_apps_dir = os.path.join(bench, 'archived_apps') shopping_cart_dir = os.path.join(bench, 'apps', 'shopping_cart') @@ -37,10 +33,11 @@ def validate_v4(bench='.'): path = os.path.join(bench, 'apps', repo) current_version = get_current_version(path) if not current_version.startswith('4'): - raise Exception("{} is not v4.x.x") + raise Exception("{} is not on v4.x.x".format(repo)) def checkout_v5(repo, bench='.'): cwd = os.path.join(bench, 'apps', repo) exec_cmd("git fetch upstream", cwd=cwd) exec_cmd("git checkout v5.0", cwd=cwd) + exec_cmd("git clean -df", cwd=cwd)