From 6fdd49b21440cd99b72eaa720c57fd9f0a1f92b7 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 20 Nov 2014 12:38:21 +0530 Subject: [PATCH] add script to migrate to version 5 --- bench/cli.py | 8 +++++++- bench/migrate_to_v5.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 bench/migrate_to_v5.py diff --git a/bench/cli.py b/bench/cli.py index dd1afc10..a64f0687 100644 --- a/bench/cli.py +++ b/bench/cli.py @@ -18,6 +18,7 @@ from .app import new_app as _new_app from .app import pull_all_apps from .config import generate_nginx_config, generate_supervisor_config from .production_setup import setup_production as _setup_production +from .migrate_to_v5 import migrate_to_v5 import os import sys import logging @@ -176,7 +177,6 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar def restart_update(kwargs): args = ['--'+k for k, v in kwargs.items() if v] - print 'restarting ' os.execv(sys.argv[0], sys.argv[:2] + args) @click.command('restart') @@ -198,6 +198,11 @@ def migrate_3to4(path): migrate_3to4=os.path.join(os.path.dirname(__file__), 'migrate3to4.py'), site=path)) +@click.command('migrate-to-v5') +def _migrate_to_v5(bench='.'): + "Migrate to Version 5" + migrate_to_v5(bench=bench) + @click.command('set-nginx-port') @click.argument('site') @click.argument('port', type=int) @@ -444,3 +449,4 @@ bench.add_command(_prime_wheel_cache) bench.add_command(_release) bench.add_command(patch) bench.add_command(set_url_root) +bench.add_command(_migrate_to_v5) diff --git a/bench/migrate_to_v5.py b/bench/migrate_to_v5.py new file mode 100644 index 00000000..6a9ee95b --- /dev/null +++ b/bench/migrate_to_v5.py @@ -0,0 +1,33 @@ +from .utils import exec_cmd, get_frappe +import os +from .release import get_current_version + +repos = ('frappe', 'erpnext') + +def migrate_to_v5(bench='.'): + .cli import restart_update + validate_v4(bench=bench) + for repo in repos: + checkout_v5(repo, bench=bench) + exec_cmd("{pip} --no-input uninstall -y shopping_cart".format(pip=os.path.join(bench, 'env', 'bin', 'pip'))) + exec_cmd("{frappe} --remove_from_installed_apps shopping_cart".format(frappe=get_frappe(bench=bench))) + restart_update({ + 'patch': True, + 'build': True, + 'requirements': True, + 'restart-supervisor': True + }) + + +def validate_v4(bench='.'): + for repo in repos: + 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") + +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) +