2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-11 15:51:03 +00:00

v5 upgrade

This commit is contained in:
Pratik Vyas 2015-03-05 15:08:39 +05:30
parent 5780ba6bd5
commit c24a904ad6
3 changed files with 46 additions and 14 deletions

View File

@ -78,22 +78,19 @@ def install_app(app, bench='.'):
find_links=find_links))
add_to_appstxt(app, bench=bench)
def pull_all_apps(bench='.', upgrade=False):
def pull_all_apps(bench='.'):
apps_dir = os.path.join(bench, 'apps')
apps = [app for app in os.listdir(apps_dir) if os.path.isdir(os.path.join(apps_dir, app))]
rebase = '--rebase' if get_config().get('rebase_on_pull') else ''
frappe_dir = os.path.join(apps_dir, 'frappe')
if not upgrade:
check_version_upgrade()
for app in apps:
app_dir = os.path.join(apps_dir, app)
if os.path.exists(os.path.join(app_dir, '.git')):
logger.info('pulling {0}'.format(app))
exec_cmd("git pull {rebase} upstream {branch}".format(rebase=rebase, branch=get_current_branch(app_dir)), cwd=app_dir)
def check_version_upgrade(bench='.'):
def is_version_upgrade(bench='.'):
apps_dir = os.path.join(bench, 'apps')
frappe_dir = os.path.join(apps_dir, 'frappe')
@ -107,7 +104,8 @@ def check_version_upgrade(bench='.'):
upstream_version = get_major_version(upstream_version)
if upstream_version - local_version > 0:
raise MajorVersionUpgradeException("Major Upgrade", upstream_version, local_version)
return True
return False
def get_current_frappe_version(bench='.'):
apps_dir = os.path.join(bench, 'apps')

View File

@ -13,10 +13,11 @@ from .utils import set_default_site as _set_default_site
from .utils import (build_assets, patch_sites, exec_cmd, update_bench, get_env_cmd, get_frappe, setup_logging,
get_config, update_config, restart_supervisor_processes, put_config, default_config, update_requirements,
backup_all_sites, backup_site, get_sites, prime_wheel_cache, is_root, set_mariadb_host, drop_privileges,
fix_file_perms, fix_prod_setup_perms, set_ssl_certificate, set_ssl_certificate_key, get_cmd_output)
fix_file_perms, fix_prod_setup_perms, set_ssl_certificate, set_ssl_certificate_key, get_cmd_output, post_upgrade,
pre_upgrade)
from .app import get_app as _get_app
from .app import new_app as _new_app
from .app import pull_all_apps, get_apps, MajorVersionUpgradeException, get_current_frappe_version
from .app import pull_all_apps, get_apps, get_current_frappe_version, is_version_upgrade
from .config import generate_nginx_config, generate_supervisor_config, generate_redis_config
from .production_setup import setup_production as _setup_production
from .migrate_to_v5 import migrate_to_v5
@ -213,13 +214,21 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
'restart-supervisor': restart_supervisor,
'upgrade': upgrade
})
if is_version_upgrade() and not upgrade:
print "This update will cause a major version change in Frappe/ERPNext."
print "This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm."
sys.exit(1)
else:
upgrade = False
if pull:
try:
pull_all_apps(upgrade=upgrade)
except MajorVersionUpgradeException, e:
print "This update will cause a major version change in Frappe/ERPNext from v{0} to v{1}.".format(e.local_version, e.upstream_version)
print "This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm."
sys.exit(1)
pull_all_apps()
if upgrade:
pre_upgrade()
if requirements:
update_requirements()
if patch:
@ -230,6 +239,8 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
build_assets()
if restart_supervisor or conf.get('restart_supervisor_on_update'):
restart_supervisor_processes()
if upgrade:
post_upgrade()
print "_"*80
print "https://frappe.io/buy - Donate to help make better free and open source tools"

View File

@ -417,4 +417,27 @@ def run_frappe_cmd(*args, **kwargs):
sites_dir = os.path.join(bench, 'sites')
subprocess.check_call((f, '-m', 'frappe.utils.bench_helper', 'frappe') + args, cwd=sites_dir)
def pre_upgrade(bench='.')
from .migrate_to_v5 import validate_v4, remove_shopping_cart
validate_v4(bench=bench)
for repo in repos:
checkout_v5(repo, bench=bench)
remove_shopping_cart(bench=bench)
def post_upgrade(bench='.'):
from .app import get_current_frappe_version
from .config import generate_nginx_config, generate_supervisor_config, generate_redis_config
if get_current_frappe_version() == 5:
print "Your bench was upgraded to version 5"
if conf.get('restart_supervisor_on_update'):
generate_redis_config(bench=bench)
generate_supervisor_config(bench=bench)
generate_nginx_config(bench=bench)
print "As you have setup your bench for production, you will have to reload configuration for nginx and supervisor"
print "To complete the migration, please run the following commands"
print
print "sudo service nginx restart"
print "sudo supervisorctl reload"
FRAPPE_VERSION = get_current_frappe_version()