V4 to V5 Upgrade - Please Help!

Hi, This has been posted on the “V5 Upgrade Instructions” as well, but maybe a separate topic is necessary for the exceptions like us, who have been having repeated issues.

Here’s my latest error when I try “bench retry-upgrade”.

Please help!! I have been stuck now for over 2 weeks. So have a few others.

promantest@promantest-erpn:~/frappe-bench$ bench retry-upgrade
From https://github.com/frappe/erpnext

  • branch develop -> FETCH_HEAD
    Already up-to-date.
    From https://github.com/frappe/frappe
  • branch develop -> FETCH_HEAD
    Already up-to-date.
    Migrating promantest.local
    Executing erpnext.patches.v5_0.update_item_description_and_image in promantest.local (promantest.local)
    Traceback (most recent call last):
    File “/usr/lib/python2.7/runpy.py”, line 162, in runmodule_as_main
    “main”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/runpy.py”, line 72, in runcode
    exec code in run_globals
    File “/home/promantest/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 77, in
    main()
    File “/home/promantest/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 14, in main
    click.Group(commands=commands)(prog_name=‘bench’)
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 664, in call
    return self.main(*args, **kwargs)
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 644, in main
    rv = self.invoke(ctx)
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 991, in invoke
    return processresult(sub_ctx.command.invoke(sub_ctx))
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 991, in invoke
    return processresult(sub_ctx.command.invoke(sub_ctx))
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 464, in invoke
    return callback(*args, **kwargs)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/commands.py”, line 28, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/commands.py”, line 205, in migrate
    frappe.modules.patch_handler.run_all()
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 25, in run_all
    if not run_single(patchmodule = patch):
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 52, in run_single
    return execute_patch(patchmodule, method, methodargs)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 68, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + “.execute”)()
    File “/home/promantest/frappe-bench/apps/erpnext/erpnext/patches/v5_0/update_item_description_and_image.py”, line 26, in execute
    frappe.reload_doctype(dt)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/init.py”, line 533, in reload_doctype
    reload_doc(scrub(db.get_value(“DocType”, doctype, “module”)), “doctype”, scrub(doctype))
    File “/home/promantest/frappe-bench/apps/frappe/frappe/init.py”, line 545, in reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/init.py”, line 37, in reload_doc
    return import_files(module, dt, dn, force=force)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 17, in import_files
    return import_file(module, dt, dn, force=force)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 22, in import_file
    ret = import_file_by_path(path, force)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 54, in import_file_by_path
    import_doc(doc, force=force, data_import=data_import)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 120, in import_doc
    doc.insert()
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/document.py”, line 194, in insert
    self.run_post_save_methods()
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/document.py”, line 559, in run_post_save_methods
    self.run_method(“on_update”)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/document.py”, line 507, in run_method
    return Document.hook(fn)(self, *args, **kwargs)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/document.py”, line 621, in composer
    return composed(self, method, *args, **kwargs)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/document.py”, line 604, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/document.py”, line 501, in
    fn = lambda self, args, **kwargs: getattr(self, method)(args, **kwargs)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 102, in on_update
    updatedb(self.name)
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/db_schema.py”, line 62, in updatedb
    tab.sync()
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/db_schema.py”, line 88, in sync
    self.alter()
    File “/home/promantest/frappe-bench/apps/frappe/frappe/model/db_schema.py”, line 237, in alter
    frappe.db.sql(“alter table {} {}”.format(self.name, ", ".join(query)))
    File “/home/promantest/frappe-bench/apps/frappe/frappe/database.py”, line 143, in sql
    self._cursor.execute(query)
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
    self.errorhandler(self, exc, value)
    File “/home/promantest/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
    raise errorclass, errorvalue
    mysqlexceptions.OperationalError: (1060, “Duplicate column name ‘test’”)
    Traceback (most recent call last):
    File “/usr/local/bin/bench”, line 9, in
    load_entry_point(‘bench==0.1’, ‘console_scripts’, ‘bench’)()
    File “/home/promantest/bench-repo/bench/cli.py”, line 55, in cli
    bench()
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 664, in call
    return self.main(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 644, in main
    rv = self.invoke(ctx)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 991, in invoke
    return processresult(sub_ctx.command.invoke(sub_ctx))
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 464, in invoke
    return callback(*args, **kwargs)
    File “/home/promantest/bench-repo/bench/cli.py”, line 263, in retry_upgrade
    patch_sites()
    File “/home/promantest/bench-repo/bench/utils.py”, line 118, in patch_sites
    run_frappe_cmd(’–site’, ‘all’, ‘migrate’, bench=bench)
    File “/home/promantest/bench-repo/bench/utils.py”, line 427, in run_frappe_cmd
    subprocess.check_call((f, ‘-m’, ‘frappe.utils.bench_helper’, ‘frappe’) + args, cwd=sites_dir)
    File “/usr/lib/python2.7/subprocess.py”, line 540, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘(’/home/promantest/frappe-bench/env/bin/python’, ‘-m’, ‘frappe.utils.bench_helper’, ‘frappe’, ‘–site’, ‘all’, ‘migrate’)’ returned non-zero exit status 1

Seems like an issue with custom fields?

Should I try to rename that Field and try bench upgrade again? Or will you guys put in a small routine that will rename existing columns that have the same name as proposed columns, so that you can sort out this issue for all future releases?

Thanks

Jay

That depends on how frequently we encounter this. Or if we find sponsors to fix it.

Yep. Understand. Thanks!