Executing erpnext.patches.v10_0.delete_hub_documents failing

That patch is failing with error

frappe.exceptions.LinkExistsError: Cannot delete or cancel because Module Def <a href="#Form/Module Def/Hub Node">Hub Node</a> is linked with DocType <a href="#Form/DocType/Hub Tracked Item">Hub Tracked Item</a>

2 Likes

There’s a lot of work going on with the hub in Develop branch and a bit in Master. Try bench update again in case it’s been fixed today

1 Like

yes several recent commits for eg https://github.com/frappe/erpnext/commit/238ed98653e917b29e874cc208700fee2b2a20db

Pleased to be able to help

well, trying to do bench update again did not solve my problem, here is the error produced during bench update

Executing erpnext.patches.v10_0.delete_hub_documents in ************************* (7125de63fb0b7549)
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/prod-bench/apps/frappe/frappe/utils/bench_helper.py”, line 94, in
main()
File “/home/frappe/prod-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/prod-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/home/frappe/prod-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/home/frappe/prod-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/prod-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/prod-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/prod-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/prod-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/prod-bench/apps/frappe/frappe/commands/init.py”, line 24, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/frappe/prod-bench/apps/frappe/frappe/commands/site.py”, line 222, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/frappe/prod-bench/apps/frappe/frappe/migrate.py”, line 31, in migrate
frappe.modules.patch_handler.run_all()
File “/home/frappe/prod-bench/apps/frappe/frappe/modules/patch_handler.py”, line 29, in run_all
if not run_single(patchmodule = patch):
File “/home/frappe/prod-bench/apps/frappe/frappe/modules/patch_handler.py”, line 63, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/frappe/prod-bench/apps/frappe/frappe/modules/patch_handler.py”, line 83, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/frappe/prod-bench/apps/erpnext/erpnext/patches/v10_0/delete_hub_documents.py”, line 15, in execute
frappe.delete_doc(“Data Migration Plan”, plan.name)
File “/home/frappe/prod-bench/apps/frappe/frappe/init.py”, line 673, in delete_doc
ignore_permissions, flags, ignore_on_trash, ignore_missing)
File “/home/frappe/prod-bench/apps/frappe/frappe/model/delete_doc.py”, line 87, in delete_doc
check_if_doc_is_linked(doc)
File “/home/frappe/prod-bench/apps/frappe/frappe/model/delete_doc.py”, line 208, in check_if_doc_is_linked
raise_link_exists_exception(doc, linked_doctype, reference_docname)
File “/home/frappe/prod-bench/apps/frappe/frappe/model/delete_doc.py”, line 260, in raise_link_exists_exception
.format(doc.doctype, doc_link, reference_doctype, reference_link, row), frappe.LinkExistsError)
File “/home/frappe/prod-bench/apps/frappe/frappe/init.py”, line 323, in throw
msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)
File “/home/frappe/prod-bench/apps/frappe/frappe/init.py”, line 309, in msgprint
_raise_exception()
File “/home/frappe/prod-bench/apps/frappe/frappe/init.py”, line 282, in _raise_exception
raise raise_exception(encode(msg))
frappe.exceptions.LinkExistsError: Cannot delete or cancel because Data Migration Plan Hub Sync is linked with Data Migration Run 7829f8131f

and i cannot access my website now, how to revert back from that bench update to be able to use my system untill it is fixed?
thanks

Make a backup and go to mysql console and delete the Data Migration Plan in question Hub Sync and try to update again

can u please send a detailed instructions?
thank you

Make a backup: bench backup
Mariadb console:bench --site sitename mariadb
From mysql: delete from `tabData Migration Plan` where name=‘Hub Sync’
Then bench update

when i enter this command in mysql : (delete from tabData Migration Plan where name=‘Hub Sync’ ) it shows me error syntax, please help, thank you

The quotes you are using in the sql statement are likely the problem… try them all (single, double, backtic) to find the ones that work!

edit: use backtick this notes https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-back-ticks-in-mysql

1 Like

still could not find correct syntax, please help guys
thank you

it should be like this

delete from [put backtick here]tabData Migration Plan[put backtick here] where name = ‘Hub Sync’

Tables in ERPNext are named like tabDocument Name normally. Hub Sync is a string you wish to compare with the primary key (the field name is the primary key of the table)

Backticks used for tables and single quote and double quotes used for string.

1 Like

i used this syntacs and still gives me error:
delete from ‘tabData Migration Plan’ where name=‘Hub Sync’;
and tried also the following and also error in syntacs:
delete from “tabData Migration Plan” where name=‘Hub Sync’;

backtick is this one `
The preferred syntax would be

delete from `tabData Migration Plan` where name=‘Hub Sync’;

1 Like

the one that worked is:

delete from `tabData Migration Plan` where name=“Hub Sync”;

Thanks alot guys,
and the bench update worked fine after wards :):smiley:

2 Likes