Want to downgrade (again)

Very sorry to post again on the same subject but the topic was closed too quick, the issue is not really solved. (Want to downgrade - #3 by hiousi)

I have this issue with last 7.1.4 and my co-workers have stopped their work since yesterday. They are unable to make any stock entry. Production is stopped for now (not in real, we are writting on papers all the material tranfers that will be typed when the issue will be fixed).

I just want to let the erpnext team solve the issue with the time they need, and in the meantime do not stop our work here. I’m unable to solve the issue by myself. So the only way I see is to reverse from 7.1.4 to 7.1.3.

@neilLasrado explained that downgrade can cause trouble.

When an update kill some necessary features, it breaks hundred of installations, why reverse upgrade is so difficult and risky? in that case, upgrade was the bad idea, downgrade is the only way I know to solve the issue immediately.

As far as I understand Git allow to go back from a commit. Will Bench permit downgrade? Should downgrade be a proposed feature?

  1. To facilitate a downgrade, assuming you have a VM, take a snapshot (including memory) of the server before an upgrade. Then you can easily revert back if needed.
  2. If ERPNext is business critical for you, you should have a staging server you can test upgrades and processes on before upgrading your main/production instance.

These are general best practices for any line-of-business application.

thanks @felix for your advices.

Staging server is great practice in software development. But it is only usefull if we can make tests. We are not developers, sure we can look around to check if the new one looks good, but it seems impossible to test the whole software at each update :frowning:

Yes our erpnext run inside a VM. I use to make a snapshot before any upgrade. the point is that some work was done before hitting the issue.

can I do that:

  • backup the 7.1.4 database
  • restore the 7.1.3 VM snapshot
  • restore 7.1.4 database to the 7.1.3 VM (to retreive all work that was done since update)
    is it the way to downgrade?

@hiousi
If you know what is your ERPNext version before upgrade, then you can easily install that version.

as @felix said, best way is to take backup/snapshot of server and then restore backup is anything is wrong.

AFAIK
You can not downgrade ERPNext, because when you do bench update code and database also get updated.
Patches are run to update database (erpnext/patches.txt at develop · frappe/erpnext · GitHub )
You need to write your own reverse patches and fix database if you want to downgrade, As there is no patches written to downgrade.

@hiousi can you please elaborate what is not working. We can fix that.

good ! @kolate_sambhaji your explanation is clear. I can undestand SQL queries and I see how I can reverse them. (or not reverse at all if they are not impacting).

@neilLasrado this is about 7.1.14 not able to make any stock entry · Issue #6796 · frappe/erpnext · GitHub and stock entry error · Issue #6787 · frappe/erpnext · GitHub

@hiousi Please run bench update. The fix has been released. Let us know incase you face any other problems.

2 Likes

@kolate_sambhaji downgraded yesterday to 7.1.3, was “easy”. did not touch the database (just pushed the 7.1.4 production database to it). the work has started again.

@neilLasrado going to copy the 7.1.4 install to a new testing instance, push the production database to it and bench update to 7.1.5. If the fix works I will do the same tonight with the current 7.1.3 production instance.

thanks for your advices.

2 Likes

I am trying to downgrade ,stuck on errror

azureuser@erpmaqtro:/home/frappe/frappe-bench$ sudo bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
INFO:bench.utils:git pull upstream master
From GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript

  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling erpnext
    INFO:bench.utils:git pull upstream master
    From GitHub - frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)
  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling mandrill_integration
    INFO:bench.utils:git pull upstream master
    From GitHub - frappe/mandrill_integration: Set Communication status from Mandrill via webhooks
  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling erpnext_shopify
    INFO:bench.utils:git pull upstream develop
    From GitHub - frappe/erpnext_shopify: [Deprecated] Shopify connector for ERPNext
  • branch develop → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling knowledge_base
    INFO:bench.utils:git pull upstream master
    From GitHub - frappe/knowledge_base: [Merged in Frappe Framework Core]
  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling schools
    INFO:bench.utils:git pull upstream develop
    From GitHub - frappe/schools: Merged with frappe/erpnext - this repo is deprecated
  • branch develop → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    INFO:bench.app:pulling poll
    INFO:bench.utils:git pull upstream master
    From GitHub - frappe/poll: Online Polling App
  • branch master → FETCH_HEAD
    Already up-to-date.
    INFO:bench.utils:find . -name “*.pyc” -delete
    Updating Python libraries…
    INFO:bench.utils:./env/bin/pip install --upgrade pip
    Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
    INFO:bench.utils:./env/bin/pip install -q -r /home/frappe/.bench/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/poll/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/knowledge_base/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/schools/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/mandrill_integration/requirements.txt
    INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext_shopify/requirements.txt
    Updating node libraries…
    INFO:bench.utils:npm install
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
    npm WARN frappe@ No description
    Backing up sites…
    Patching sites…
    Migrating site1.local
    Executing erpnext.patches.v8_0.merge_student_batch_and_student_group in site1.local (1bd3e0294da19198)
    Traceback (most recent call last):
    File “/usr/lib/python2.7/runpy.py”, line 174, in _run_module_as_main
    main”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/runpy.py”, line 72, in _run_code
    exec code in run_globals
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
    main()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
    click.Group(commands=commands)(prog_name=‘bench’)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 716, in call
    return self.main(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 696, in main
    rv = self.invoke(ctx)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 534, in invoke
    return callback(*args, **kwargs)
    File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py”, line 217, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
    frappe.modules.patch_handler.run_all()
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
    if not run_single(patchmodule = patch):
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + “.execute”)()
    File “/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v8_0/merge_student_batch_and_student_group.py”, line 24, in execute
    “batch_name”: student_batch.get(“batch”)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 622, in get_doc
    return frappe.model.document.get_doc(arg1, arg2)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 49, in get_doc
    controller = get_controller(doctype)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 35, in get_controller
    module = load_doctype_module(doctype, module_name)
    File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 185, in load_doctype_module
    raise ImportError(‘Module import failed for {0} ({1})’.format(doctype, module_name + ’ Error: ’ + str(e)))
    ImportError: Module import failed for Student Batch Name (frappe.core.doctype.student_batch_name.student_batch_name Error: No module named student_batch_name.student_batch_name)
    azureuser@erpmaqtro:/home/frappe/frappe-bench$