Bench migrate fails with frappe.database.database.Database.InvalidColumnName: Invalid field name

I was trying to do bench migrate after importing backup from V11 to V13 bench
This fails at

Executing erpnext.patches.v12_0.set_cwip_and_delete_asset_settings in sitename

Any suggestions how to get around this issue?
Full stacktrace of the migrate operation below:

Executing erpnext.patches.v12_0.set_cwip_and_delete_asset_settings in erp.sitename.com (_be11ba66cd4dc7f6)

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/utils/bench_helper.py", line 110, in <module>
    main()
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/ubuntu/erpnext-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/erpnext-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/erpnext-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/erpnext-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/erpnext-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/erpnext-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/erpnext-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/commands/__init__.py", line 31, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/commands/site.py", line 433, in migrate
    migrate(context.verbose, skip_failing=skip_failing, skip_search_index=skip_search_index)
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/migrate.py", line 73, in migrate
    frappe.modules.patch_handler.run_all(skip_failing)
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/modules/patch_handler.py", line 47, in run_all
    run_patch(patch)
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/modules/patch_handler.py", line 36, in run_patch
    if not run_single(patchmodule=patch):
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/modules/patch_handler.py", line 81, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/modules/patch_handler.py", line 105, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/ubuntu/erpnext-bench/apps/erpnext/erpnext/patches/v12_0/set_cwip_and_delete_asset_settings.py", line 11, in execute
    cwip_value = frappe.db.get_single_value("Asset Settings", "disable_cwip_accounting")
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/database/database.py", line 681, in get_single_value
    frappe.throw(
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/__init__.py", line 504, in throw
    msgprint(
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/__init__.py", line 479, in msgprint
    _raise_exception()
  File "/home/ubuntu/erpnext-bench/apps/frappe/frappe/__init__.py", line 434, in _raise_exception
    raise raise_exception(msg)
frappe.database.database.Database.InvalidColumnName: Invalid field name: <b>disable_cwip_accounting</b>

OS is Ubuntu server 22.04 LTS

Hi,

Has the 11 data been migrated to 12 as an intermediate step?

There are many problems when trying to migrate the database from one version to another…
The main reason is that the database schema in v11, for example, is different from the database schema in v13… (some fields are created, so when merging does not find these fields and it fails)…

1 Like

Hi!

We have not yet tried to migrate it to V12 as we could not get V12 environment to install at all with Ubuntu server 22.04. I will try to get it working on Ubuntu 20.04 next and do the V11 → V12 migration there then move that to V13, I’ll report back soon how it went.

Same error is thrown when migrating from V11 to V12. It also looks like the V12 requires python 2 and python2 pip? I had to install those and set them up as defaults in order to get the V12 to even setup…

Managed to get the migrartion to work without error messages as follows:

First I had to upgrade the current installation to latest V11 release:

bench setup requirements #We had some missing dependencies as well, this fixed those
redis-cli -p 13000 FLUSHALL #Had to run this to get rid of some errors
bench update --pull --patch --no-backup --reset #Update to latest V11

After this the upgrade to V12 was successfull on the old server:

redis-cli -p 13000 FLUSHALL
bench switch-to-branch version-12 --upgrade
bench update --patch --no-backup

After this I exported backup with bench backup --with-files and restored this to V13 bench and ran bench --site sitename migrate