Yes, actually @clarkej is right, I can confirm it.
I just checked on a v12 instance that i have and where he pointed to the json file is there in automation. The exact path:
/apps/frappe/frappe/automation/doctype/milestone_tracker/milestone_tracker.json
Thanks, it worked.! but I still have a question. Why it this happening? and how can I avoid that. because, that’s a fresh server, those DocTypes must be in there rigth?
Well, migrate runs and applies any current patches once and only once. A given patch assumes and can change how a DocType is defined; when that version definition as stored in memory differs from its table schema defined in the database, the two are out of sync - this mismatch results in error tracebacks.
My guess is out of sync cases can arise where some later patch is applied that operates on a ‘stale’ DocType from an earlier defined version. In that case one must manually reload the DocType to its current version?
I can’t say how you avoid this - to identify and fix patch issues? Frappe and the community try hard to address such problems…
edit: These may help to get more sense here:
https://support.erpnext.com/docs/user/en/tutorial/models
Hello I ran the Method 2, this is what I got.
Migrating site1.local
Executing frappe.patches.v12_0.remove_deprecated_fields_from_doctype #3 in site1.local (_1bd3e0294da19198)
Success: Done in 1.255s
Executing frappe.patches.v11_0.drop_column_apply_user_permissions in site1.local (_1bd3e0294da19198)
Success: Done in 1.327s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docfield’, force=True) #2018-02-20 in site1.local (_1bd3e0294da19198)
Success: Done in 1.757s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘docperm’) #2018-05-29 in site1.local (_1bd3e0294da19198)
Success: Done in 0.051s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘comment’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.528s
Executing execute:frappe.reload_doc(‘email’, ‘doctype’, ‘document_follow’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.655s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘communication_link’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.269s
Executing execute:frappe.reload_doc(‘core’, ‘doctype’, ‘communication’) in site1.local (_1bd3e0294da19198)
Success: Done in 1.364s
Executing frappe.patches.v11_0.replicate_old_user_permissions in site1.local (_1bd3e0294da19198)
Success: Done in 24.126s
Executing frappe.patches.v11_0.reload_and_rename_view_log #2019-01-03 in site1.local (_1bd3e0294da19198)
Success: Done in 0.268s
Executing frappe.patches.v11_0.copy_fetch_data_from_options in site1.local (_1bd3e0294da19198)
Success: Done in 3.261s
Executing frappe.patches.v11_0.change_email_signature_fieldtype in site1.local (_1bd3e0294da19198)
Success: Done in 1.289s
Executing frappe.patches.v10_0.refactor_social_login_keys in site1.local (_1bd3e0294da19198)
Success: Done in 2.006s
Executing frappe.patches.v10_0.enable_chat_by_default_within_system_settings in site1.local (_1bd3e0294da19198)
Success: Done in 3.679s
Executing frappe.patches.v10_0.remove_custom_field_for_disabled_domain in site1.local (_1bd3e0294da19198)
Success: Done in 0.571s
Executing execute:frappe.delete_doc(“Page”, “chat”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.495s
Executing frappe.patches.v10_0.migrate_passwords_passlib in site1.local (_1bd3e0294da19198)
Success: Done in 3.234s
Executing frappe.patches.v11_0.rename_standard_reply_to_email_template in site1.local (_1bd3e0294da19198)
Success: Done in 0.131s
Executing execute:frappe.delete_doc_if_exists(‘Page’, ‘user-permissions’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.051s
Executing frappe.patches.v11_0.create_contact_for_user in site1.local (_1bd3e0294da19198)
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/site.py”, line 233, in migrate
migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
File “/home/interra/frappe-bench/apps/frappe/frappe/migrate.py”, line 48, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 41, in run_all
run_patch(patch)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/interra/frappe-bench/apps/frappe/frappe/patches/v11_0/create_contact_for_user.py”, line 23, in execute
create_contact(user, ignore_links=True, ignore_mandatory=True)
File “/home/interra/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py”, line 1047, in create_contact
contact.insert(ignore_permissions=True, ignore_links=ignore_links, ignore_mandatory=ignore_mandatory)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 252, in insert
self.run_method(“after_insert”)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 786, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1056, in composer
return composed(self, method, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1041, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/interra/frappe-bench/apps/erpnext/erpnext/communication/doctype/call_log/call_log.py”, line 89, in set_caller_information
logs = frappe.get_all(‘Call Log’, filters=filters)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 1299, in get_all
return get_list(doctype, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 1272, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 95, in execute
result = self.build_and_run()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 109, in build_and_run
args = self.prepare_args()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 135, in prepare_args
self.set_optional_columns()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 293, in set_optional_columns
columns = frappe.db.get_table_columns(self.doctype)
File “/home/interra/frappe-bench/apps/frappe/frappe/database/database.py”, line 857, in get_table_columns
raise self.TableMissingError
pymysql.err.ProgrammingError
Please can you assist in resolving this? Thank you.
If you run an update the code now lists the name of the missing table -
You stack trace suggests Call Log is missing?
See if this helps:
bench reload-doc communication doctype call_log
Hello @clarkej
Thanks for your respnonse. After running bench reload-doc communication doctype call_log this is what I am getting;
Traceback (most recent call last):
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 204, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(module_name)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 808, in get_module
return importlib.import_module(modulename)
File “/home/interra/frappe-bench/env/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 941, in _find_and_load_unlocked
File “”, line 219, in _call_with_frames_removed
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘frappe.core.doctype.energy_point_settings’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/site.py”, line 265, in reload_doc
frappe.reload_doc(module, doctype, docname, force=context.force)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 799, in reload_doc
return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 174, in reload_doc
return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 27, in import_files
reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 32, in import_file
ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 66, in import_file_by_path
ignore_version=ignore_version, reset_permissions=reset_permissions)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/import_file.py”, line 141, in import_doc
doc.insert()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 258, in insert
self.run_post_save_methods()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 917, in run_post_save_methods
self.run_method(“on_update”)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 786, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1056, in composer
return composed(self, method, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1039, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 780, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 284, in on_update
make_module_and_roles(self)
File “/home/interra/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py”, line 1119, in make_module_and_roles
m.insert()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 258, in insert
self.run_post_save_methods()
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 927, in run_post_save_methods
self.run_method(‘on_change’)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 786, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1056, in composer
return composed(self, method, *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 1041, in runner
add_to_return_value(self, f(self, method, *args, **kwargs))
File “/home/interra/frappe-bench/apps/frappe/frappe/social/doctype/energy_point_rule/energy_point_rule.py”, line 85, in process_energy_points
or not is_energy_point_enabled()):
File “/home/interra/frappe-bench/apps/frappe/frappe/social/doctype/energy_point_settings/energy_point_settings.py”, line 15, in is_energy_point_enabled
return frappe.get_cached_value(‘Energy Point Settings’, None, ‘enabled’)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 706, in get_cached_value
doc = get_cached_doc(doctype, name)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 691, in get_cached_doc
doc = get_doc(*args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/init.py”, line 734, in get_doc
doc = frappe.model.document.get_doc(*args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/document.py”, line 67, in get_doc
controller = get_controller(doctype)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 47, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 206, in load_doctype_module
raise ImportError(‘Module import failed for {0} ({1})’.format(doctype, module_name + ’ Error: ’ + str(e)))
ImportError: Module import failed for Energy Point Settings (frappe.core.doctype.energy_point_settings.energy_point_settings Error: No module named ‘frappe.core.doctype.energy_point_settings’)
Please is there any other command I can run to resolve this error? Thanks for your support.
ok what to do here for clues and pointers to proceed, try this -
-
search up ‘ImportError: Module import failed for’
-
apply that q&a advice in your case here for the ‘Energy Point Settings’ module
You may also want to start a new thread for further tips and advice
Ok this is what I have found out from the last error I encountered. I temporarily cleared all patches on frappe and erpnext by going to apps/frappe/frappe/patches.txt from my frappe-bench directory and apps/erpnext/erpnext/patches.txt. I ran bench migrate which restored the database. After which I ran bench update --reset.
This cleared the ImportError I posted as my last snag. However, I am encountering another snag which I am hoping someone might help me with a clue in resolving the error.
This is the traceback I am having;
Traceback (most recent call last):
File “/usr/lib/python3.6/runpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “/usr/lib/python3.6/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/interra/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/commands/site.py”, line 233, in migrate
migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
File “/home/interra/frappe-bench/apps/frappe/frappe/migrate.py”, line 48, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 41, in run_all
run_patch(patch)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/interra/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/interra/frappe-bench/apps/erpnext/erpnext/patches/v11_0/rename_production_order_to_work_order.py”, line 10, in execute
rename_doc(‘DocType’, ‘Production Order’, ‘Work Order’, force=True)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/rename_doc.py”, line 43, in rename_doc
rename_parent_and_child(doctype, old, new, meta)
File “/home/interra/frappe-bench/apps/frappe/frappe/model/rename_doc.py”, line 138, in rename_parent_and_child
frappe.db.sql(“UPDATE tab{0}
SET name
={1} WHERE name
={1}”.format(doctype, ‘%s’), (new, old))
File “/home/interra/frappe-bench/apps/frappe/frappe/database/database.py”, line 156, in sql
self._cursor.execute(query, values)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/interra/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, “Duplicate entry ‘Work Order’ for key ‘PRIMARY’”)
I would be grateful for any contribution in resolving this error. Thank you.
Hello,
does anyone has any clue to resolving this error?
Which version are you on. The logs seem to indicate version 11, while you say you should be on 12.
Hi again, Can you explain the reload-doc command, because I run it and it worked, but when I restore another site in the same erpnext instance, the console throws the same error, and I though that document was in there already when I run that command,
that command download the doctype file in the server again? o…?
thanks in advance
In a multi-tenant case, all the tenants share one single codebase (for example, DocType versions defined in apps like erpnext and frappe).
But likewise in a multi-tenant case, each tenant’s data set restore must be migrated and patches applied to their data set. So patches may possibly raise an error that requires another (earlier?) DocType version, so the case for reload-doc may occur, or to add or change a patch.
That said YMMV - what you observe may differ from my own tentative theory, as I have no practical experience with multi-tenant migration…
This post may help with your understanding Need a better understanding of MultiTenant configurations
On second thought this struck me - in the multi-tenant case do each restore and migrate into a clean single site instance as Zlash65 outlines in Method 1.
Then, once the data has been migrated to current in that instance, backup and restore that data into the multi-tenant instance.
That process would be more rigourous practice less subject to losing or corrupting data.
To use a VM here would help - to save and restore snapshots to switch instances.
is there a workaround to reload-doc to a specific site? (something like bench reload-doc communication doctype call_log --site [site-name] ). Because, I run the command and its seems like its not working now, but in the main site it worked.
No the architecture does not support that I am am aware - but you could create separate bench instances, one for each site, as revant_one explains here Multiple Bench Instance
That way a given bench would serve an individual codebase dedicated to a given site.
You may want to study his multi-tenant architecture diagram to grasp how the parts relate Need a better understanding of MultiTenant configurations - #4 by revant_one
thanks @clarkej, As a workaround , I change de default site using
bench use [site-name]
then I run the command
bench reload-doc communication doctype call_log
and It worked.
Excellent thanks for your followup to point out that workaround…
This worked a treat! I did find an error in the Error Log view but doing the following fixed that:
bench reload-doc desk doctype event_participants