Error Updating from V10 to V12

Hi all,

encountered the following error while trying to update from V10 to V12. The V10 instance itself was originally restored from another V10 backup

Executing frappe.patches.v11_0.create_contact_for_user in sf.xxxxxxxxx.com (a58f8b45f303c856)
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-bench2/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench2/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-bench2/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/commands/site.py", line 233, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/migrate.py", line 48, in migrate
    frappe.modules.patch_handler.run_all(skip_failing)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 41, in run_all
    run_patch(patch)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 30, in run_patch
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 71, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 91, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench2/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/frappe/frappe-bench2/apps/frappe/frappe/core/doctype/user/user.py", line 1049, in create_contact
    contact.insert(ignore_permissions=True, ignore_links=ignore_links, ignore_mandatory=ignore_mandatory)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/document.py", line 252, in insert
    self.run_method("after_insert")
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/document.py", line 786, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/document.py", line 1056, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/document.py", line 1041, in runner
    add_to_return_value(self, f(self, method, *args, **kwargs))
  File "/home/frappe/frappe-bench2/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/frappe/frappe-bench2/apps/frappe/frappe/__init__.py", line 1299, in get_all
    return get_list(doctype, *args, **kwargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/__init__.py", line 1272, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/db_query.py", line 95, in execute
    result = self.build_and_run()
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/db_query.py", line 109, in build_and_run
    args = self.prepare_args()
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/db_query.py", line 135, in prepare_args
    self.set_optional_columns()
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/db_query.py", line 293, in set_optional_columns
    columns = frappe.db.get_table_columns(self.doctype)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/database/database.py", line 857, in get_table_columns
    raise self.TableMissingError
pymysql.err.ProgrammingError

Any assistance will be greatly appreciated

Thanks

Hi @wale,

from what I see the patch frappe.patches.v11_0.create_contact_for_user fails with a missing table. Can you check if you have “tabUser”, “tabContact” and “tabDocType”? We have also seen in upgrades very strange symptoms where suddenly during the update a table was completely dropped and had to be restored from a backup. Unfortunately, so far we were never able to reproduce this and it seems to hit in random places (seen in Translation and custom DocTypes)…

Last resort: you can mark the patch as executed in the tabPatch Log. In this case, make sure each user has a Contact, then marking it done should be safe.

Hi @lasalesi

Thanks for your response

Could you give steps for this please?

…And for this also

Thanks

$ bench --site yoursite.com mariadb
> show tables;

Then browse the tables (there are other ways as well, this is just one option). In case a table is really missing, either restore everything or (as we did), individually restore the missing table. You can extract the code block from the backup (open with an editor, find the table definition and paste it as a command into a MySQL shell, or extract as individual .sql file and run it on the respective database.

> SELECT * FROM `tabPatch Log`;

Look at the structure and then use INSERT to insert manually a Patch Log Entry… Or use a tool (e.g. MySQL workbench, Libreoffice Base) to do this from a GUI. This will force the updater to jump over this patch…

Thanks a lot. Will try this and revert…

So I commented out the patch and used bench migrate just to move things along quicker and see if there are other possible snags along the way. This is the current error message:

Executing erpnext.patches.v10_1.transfer_subscription_to_auto_repeat in s.xxxxxxx.com (a58f8b45f303c856)
/home/frappe/frappe-bench2/apps/frappe/frappe/desk/doctype/auto_repeat/auto_repeat.json missing
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-bench2/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench2/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench2/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-bench2/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/commands/site.py", line 233, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/migrate.py", line 48, in migrate
    frappe.modules.patch_handler.run_all(skip_failing)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 41, in run_all
    run_patch(patch)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 30, in run_patch
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 71, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/modules/patch_handler.py", line 91, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench2/apps/erpnext/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py", line 27, in execute
    auto_repeat = frappe.get_doc(doc)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/__init__.py", line 734, in get_doc
    doc = frappe.model.document.get_doc(*args, **kwargs)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/document.py", line 67, in get_doc
    controller = get_controller(doctype)
  File "/home/frappe/frappe-bench2/apps/frappe/frappe/model/base_document.py", line 47, in get_controller
    module = load_doctype_module(doctype, module_name)
  File "/home/frappe/frappe-bench2/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 Auto Repeat (frappe.core.doctype.auto_repeat.auto_repeat Error: No module named auto_repeat.auto_repeat)

Any ideas please?

Kind regards,

Hi @wale,

this is now the next patch failing. We just had another instance update from v10 to v12 with many issues. What helped was to remove all patches in frappe and erpnext (temporarily clear apps/frappe/frappe/patches.txt and apps/erpnext/erpnext/patches.txt, then running

$ bench migrate

which restored the databases and then ran

$ bench update --reset

to process the patches. This helped push things through, but still had to resolve many patch issues (most frustratingly with modules healthcare that isn’t even used…). Hope this helps…

Hi @lasalesi

If I get you correctly, the bench update --reset brought back the failing patches but the site was accessible (and usable) after bench migrate?

Correct! We only want the patches of so that the database can be migrated properly. I actually suspect there is an architectural issue here - migration of the tables should be before the patching… At least some of the recent patches will fail (what we see very often since v12)

1 Like

Thanks a lot for the assistance… will proceed accordingly

Kind regrads,

Hello, please my first question is this; how can I know the tables that are missing, and restore them individually?
Secondly, how do you extract the code block from the backup when one is already in production mode?
I actually have a similar situation, so I’m trying to understand the solution you stated so that I can try it out myself.
Thank you.

I got the same error that in the first message. Is there anybody who update from v10 to v12? I can’t solve :confused:

The tables that are missing are mostly shown as errors in the migration scripts. If you have the old database, use

> show tables;

and compare against the new database.

If you have your backup, it is a self-contained SQL file. You can open the .sql file with any text editor (e.g. Geany, Notepad++, …), if it is a .gz, extract. Find the code block corresponding to “tabYour Table”. Once you have this, you can copy & paste into the SQL console. Executing the code will create the table and load the data.

Hope this helps.

Hello @lasalesi, thank you for your response.
I followed your instructions so far under this topic, and I have been able to resolve the error. However, when I ran bench update --reset, I encountered this error;

nkemakolam@ubuntu:/home/interra/frappe-bench$ sudo bench update --reset
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/python3.6/site-packages (6.2.0)
Backing up sites…
INFO:bench.app:pulling frappe
INFO:bench.utils:git fetch --all
Fetching upstream
INFO:bench.utils:git reset --hard upstream/version-12
HEAD is now at bb3d43556 fix(list-view): Remove ugly scroll from list view
INFO:bench.utils:find . -name “.pyc" -delete
INFO:bench.app:pulling erpnext
INFO:bench.utils:git fetch --all
Fetching upstream
INFO:bench.utils:git reset --hard upstream/version-12
HEAD is now at c5a6e9da15 Merge branch ‘develop’ into version-12
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/python3.6/site-packages (19.2.3)
INFO:bench.utils:./env/bin/pip install -q -r /home/interra/.bench/requirements.txt
INFO:bench.app:installing frappe
INFO:bench.utils:./env/bin/pip install -q -e ./apps/frappe
INFO:bench.app:installing erpnext
INFO:bench.utils:./env/bin/pip install -q -e ./apps/erpnext
Updating node packages…
INFO:bench.utils:yarn install
yarn install v1.19.1
[1/4] Resolving packages…
success Already up-to-date.
Done in 1.05s.
INFO:bench.utils:yarn install
yarn install v1.19.1
[1/4] Resolving packages…
success Already up-to-date.
Done in 2.51s.
Patching sites…
Migrating site1.local
Executing frappe.patches.v11_0.create_contact_for_user in site1.local (_1bd3e0294da19198)
Success: Done in 57.758s
Executing frappe.patches.v11_0.sync_stripe_settings_before_migrate in site1.local (_1bd3e0294da19198)
Success: Done in 0.07s
Executing frappe.patches.v11_0.update_list_user_settings in site1.local (_1bd3e0294da19198)
Success: Done in 0.327s
Executing frappe.patches.v11_0.rename_workflow_action_to_workflow_action_master #13-06-2018 in site1.local (_1bd3e0294da19198)
Success: Done in 0.167s
Executing frappe.patches.v11_0.rename_email_alert_to_notification #13-06-2018 in site1.local (_1bd3e0294da19198)
Success: Done in 0.142s
Executing frappe.patches.v11_0.delete_duplicate_user_permissions in site1.local (_1bd3e0294da19198)
Success: Done in 0.06s
Executing frappe.patches.v11_0.set_dropbox_file_backup in site1.local (_1bd3e0294da19198)
Success: Done in 0.053s
Executing frappe.patches.v11_0.rename_google_maps_doctype in site1.local (_1bd3e0294da19198)
/home/interra/frappe-bench/apps/frappe/frappe/integrations/doctype/google_maps_settings/google_maps_settings.json missing
Success: Done in 4.009s
Executing frappe.patches.v10_0.modify_smallest_currency_fraction in site1.local (_1bd3e0294da19198)
Success: Done in 0.061s
Executing frappe.patches.v10_0.modify_naming_series_table in site1.local (_1bd3e0294da19198)
Success: Done in 0.234s
Executing frappe.patches.v10_0.enhance_security in site1.local (_1bd3e0294da19198)
Success: Done in 3.841s
Executing frappe.patches.v11_0.multiple_references_in_events in site1.local (_1bd3e0294da19198)
Success: Done in 0.083s
Executing frappe.patches.v11_0.set_allow_self_approval_in_workflow in site1.local (_1bd3e0294da19198)
Success: Done in 0.08s
Executing frappe.patches.v11_0.remove_skip_for_doctype in site1.local (_1bd3e0294da19198)
Success: Done in 37.155s
Executing frappe.patches.v11_0.migrate_report_settings_for_new_listview in site1.local (_1bd3e0294da19198)
Success: Done in 0.103s
Executing frappe.patches.v11_0.delete_all_prepared_reports in site1.local (_1bd3e0294da19198)
Success: Done in 0.088s
Executing frappe.patches.v11_0.fix_order_by_in_reports_json in site1.local (_1bd3e0294da19198)
Success: Done in 0.181s
Executing execute:frappe.delete_doc(‘Page’, ‘applications’, ignore_missing=True) in site1.local (_1bd3e0294da19198)
Success: Done in 0.364s
Executing frappe.patches.v11_0.set_missing_creation_and_modified_value_for_user_permissions in site1.local (_1bd3e0294da19198)
Success: Done in 0.086s
Executing frappe.patches.v11_0.set_default_letter_head_source in site1.local (_1bd3e0294da19198)
Success: Done in 0.065s
Executing frappe.patches.v12_0.set_primary_key_in_series in site1.local (_1bd3e0294da19198)
Success: Done in 0.148s
Executing execute:frappe.delete_doc(“Page”, “modules”, ignore_missing=True) in site1.local (_1bd3e0294da19198)
Success: Done in 0.16s
Executing frappe.patches.v12_0.setup_comments_from_communications in site1.local (_1bd3e0294da19198)
Success: Done in 9.736s
Executing frappe.patches.v12_0.init_desk_settings #16-05-2019 in site1.local (_1bd3e0294da19198)
Success: Done in 0.257s
Executing frappe.patches.v12_0.replace_null_values_in_tables in site1.local (_1bd3e0294da19198)
Success: Done in 0.778s
Executing frappe.patches.v12_0.reset_home_settings in site1.local (_1bd3e0294da19198)
Success: Done in 0.086s
Executing frappe.patches.v12_0.update_print_format_type in site1.local (_1bd3e0294da19198)
Success: Done in 0.11s
Executing frappe.patches.v11_0.remove_doctype_user_permissions_for_page_and_report #2019-05-01 in site1.local (_1bd3e0294da19198)
Success: Done in 0.434s
Executing frappe.patches.v11_0.apply_customization_to_custom_doctype in site1.local (_1bd3e0294da19198)
Success: Done in 0.104s
Executing frappe.patches.v12_0.remove_feedback_rating in site1.local (_1bd3e0294da19198)
Success: Done in 0.447s
Executing frappe.patches.v12_0.move_form_attachments_to_attachments_folder in site1.local (_1bd3e0294da19198)
Success: Done in 0.09s
Executing frappe.patches.v12_0.move_timeline_links_to_dynamic_links in site1.local (_1bd3e0294da19198)
Success: Done in 0.125s
Executing frappe.patches.v12_0.delete_feedback_request_if_exists #1 in site1.local (_1bd3e0294da19198)
Success: Done in 0.083s
Executing frappe.patches.v12_0.rename_events_repeat_on in site1.local (_1bd3e0294da19198)
Success: Done in 0.155s
Executing frappe.patches.v12_0.fix_public_private_files in site1.local (_1bd3e0294da19198)
Success: Done in 0.099s
Executing frappe.patches.v12_0.move_email_and_phone_to_child_table in site1.local (_1bd3e0294da19198)
Success: Done in 0.765s
Executing frappe.patches.v12_0.delete_duplicate_indexes in site1.local (_1bd3e0294da19198)
Success: Done in 0.889s
Executing frappe.patches.v12_0.set_default_incoming_email_port in site1.local (_1bd3e0294da19198)
Success: Done in 1.499s
Executing frappe.patches.v12_0.update_global_search in site1.local (_1bd3e0294da19198)
Success: Done in 0.359s
Executing erpnext.patches.v11_0.rename_production_order_to_work_order 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/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’”)

Please can you also direct me on how to resolve this error if you have a clue about this?
Thank you so much.

Hi @Nwokoro_Nkemakolam,

personally, I would take the easy way and open MariaDB, open the “tabPatch Log” and create a manual entry for erpnext.patches.v11_0.rename_production_order_to_work_order, your failing patch. This way it is marked as executed and should run through. The root cause is probably an issue in the patch logic with your data. In case you are really using production orders, manually check if the table content makes sense.

Hello @lasalesi,
Thank you for your response. I have opened the tabPatch Log but I do not know how to create a manual entry for erpnext.patches.v11.rename_production_order_to_work_order. How do I create this entry manually?
Thanks for your support.

Use a statement like this:

INSERT INTO `tabPatch Log` (`name`, `creation`, `modified`, `modified_by`, `owner`, `docstatus`, `idx`, `patch`) VALUES ('PATCHLOG00930-1', '2019-10-15 11:47:41.259451', '2019-10-15 11:47:41.259451', 'Administrator', 'Administrator', '0', '0', 'erpnext.patches.v12_0.set_default_shopify_app_type');

where you insert your path name and the first ID needs to be unique (but not the logically next, this will be used by the updater, so when you use …-1 you can easily see which was manual)

1 Like

Wow! Thanks @lasalesi, you’re really very good, and your solution worked!. Unfortunately, I still encountered another error. Can you still help me with this also?

nkemakolam@ubuntu:/home/interra/frappe-bench$ sudo bench update --reset
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/python3.6/site-packages (6.2.0)
Backing up sites…
INFO:bench.app:pulling frappe
INFO:bench.utils:git fetch --all
Fetching upstream
INFO:bench.utils:git reset --hard upstream/version-12
HEAD is now at bb3d43556 fix(list-view): Remove ugly scroll from list view
INFO:bench.utils:find . -name “.pyc" -delete
INFO:bench.app:pulling erpnext
INFO:bench.utils:git fetch --all
Fetching upstream
INFO:bench.utils:git reset --hard upstream/version-12
HEAD is now at c5a6e9d Merge branch ‘develop’ into version-12
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/python3.6/site-packages (19.3)
INFO:bench.utils:./env/bin/pip install -q -r /home/interra/.bench/requirements.txt
INFO:bench.app:installing frappe
INFO:bench.utils:./env/bin/pip install -q -e ./apps/frappe
INFO:bench.app:installing erpnext
INFO:bench.utils:./env/bin/pip install -q -e ./apps/erpnext
Updating node packages…
INFO:bench.utils:yarn install
yarn install v1.19.1
[1/4] Resolving packages…
success Already up-to-date.
Done in 0.96s.
INFO:bench.utils:yarn install
yarn install v1.19.1
[1/4] Resolving packages…
success Already up-to-date.
Done in 3.37s.
Patching sites…
Migrating site1.local
Executing erpnext.patches.v11_0.rename_supplier_type_to_supplier_group in site1.local (_1bd3e0294da19198)
Success: Done in 0.437s
Executing erpnext.patches.v10_1.transfer_subscription_to_auto_repeat in site1.local (_1bd3e0294da19198)
/home/interra/frappe-bench/apps/frappe/frappe/desk/doctype/auto_repeat/auto_repeat.json missing
Success: Done in 3.04s
Executing erpnext.patches.v11_0.update_brand_in_item_price in site1.local (_1bd3e0294da19198)
Success: Done in 0.183s
Executing erpnext.patches.v11_0.create_default_success_action in site1.local (_1bd3e0294da19198)
Success: Done in 0.536s
Executing erpnext.patches.v11_0.add_healthcare_service_unit_tree_root in site1.local (_1bd3e0294da19198)
Success: Done in 0.182s
Executing erpnext.patches.v11_0.rename_field_max_days_allowed in site1.local (_1bd3e0294da19198)
Success: Done in 0.485s
Executing erpnext.patches.v11_0.create_salary_structure_assignments in site1.local (_1bd3e0294da19198)
Success: Done in 0.571s
Executing erpnext.patches.v11_0.rename_health_insurance in site1.local (_1bd3e0294da19198)
Success: Done in 0.113s
Executing erpnext.patches.v11_0.rebuild_tree_for_company in site1.local (_1bd3e0294da19198)
Success: Done in 0.182s
Executing erpnext.patches.v11_0.create_department_records_for_each_company in site1.local (_1bd3e0294da19198)
Success: Done in 4.475s
Executing erpnext.patches.v11_0.make_location_from_warehouse in site1.local (_1bd3e0294da19198)
Success: Done in 0.125s
Executing erpnext.patches.v11_0.make_asset_finance_book_against_old_entries in site1.local (_1bd3e0294da19198)
Success: Done in 0.43s
Executing erpnext.patches.v11_0.check_buying_selling_in_currency_exchange in site1.local (_1bd3e0294da19198)
Success: Done in 0.136s
Executing erpnext.patches.v11_0.move_item_defaults_to_child_table_for_multicompany #02-07-2018 #19-06-2019 in site1.local (_1bd3e0294da19198)
Success: Done in 0.126s
Executing erpnext.patches.v11_0.refactor_erpnext_shopify #2018-09-07 in site1.local (_1bd3e0294da19198)
Success: Done in 0.571s
Executing erpnext.patches.v11_0.rename_overproduction_percent_field in site1.local (_1bd3e0294da19198)
Success: Done in 0.274s
Executing erpnext.patches.v11_0.update_backflush_subcontract_rm_based_on_bom in site1.local (_1bd3e0294da19198)
Success: Done in 0.107s
Executing erpnext.patches.v11_0.inter_state_field_for_gst in site1.local (_1bd3e0294da19198)
Success: Done in 0.11s
Executing erpnext.patches.v11_0.rename_members_with_naming_series #04-06-2018 in site1.local (_1bd3e0294da19198)
Success: Done in 0.117s
Executing erpnext.patches.v11_0.set_update_field_and_value_in_workflow_state in site1.local (_1bd3e0294da19198)
Success: Done in 0.074s
Executing erpnext.patches.v11_0.update_total_qty_field in site1.local (_1bd3e0294da19198)
Success: Done in 1.276s
Executing erpnext.patches.v11_0.update_sales_partner_type in site1.local (_1bd3e0294da19198)
Success: Done in 0.428s
Executing erpnext.patches.v11_0.rename_asset_adjustment_doctype in site1.local (_1bd3e0294da19198)
Success: Done in 0.101s
Executing erpnext.patches.v11_0.set_salary_component_properties in site1.local (_1bd3e0294da19198)
Success: Done in 0.147s
Executing erpnext.patches.v11_0.set_user_permissions_for_department in site1.local (_1bd3e0294da19198)
Success: Done in 0.091s
Executing erpnext.patches.v11_0.hr_ux_cleanups in site1.local (_1bd3e0294da19198)
Success: Done in 0.242s
Executing erpnext.patches.v11_0.skip_user_permission_check_for_department in site1.local (_1bd3e0294da19198)
Success: Done in 0.145s
Executing erpnext.patches.v11_0.set_department_for_doctypes in site1.local (_1bd3e0294da19198)
Success: Done in 0.629s
Executing erpnext.patches.v11_0.update_allow_transfer_for_manufacture in site1.local (_1bd3e0294da19198)
Success: Done in 0.102s
Executing erpnext.patches.v11_0.add_item_group_defaults in site1.local (_1bd3e0294da19198)
Success: Done in 0.189s
Executing erpnext.patches.v11_0.add_expense_claim_default_account in site1.local (_1bd3e0294da19198)
Success: Done in 0.115s
Executing execute:frappe.delete_doc(“Page”, “hub”) in site1.local (_1bd3e0294da19198)
Success: Done in 2.688s
Executing erpnext.patches.v11_0.reset_publish_in_hub_for_all_items in site1.local (_1bd3e0294da19198)
Success: Done in 0.086s
Executing erpnext.patches.v11_0.update_hub_url # 2018-08-31 # 2018-09-03 in site1.local (_1bd3e0294da19198)
Success: Done in 0.087s
Executing erpnext.patches.v10_0.set_discount_amount in site1.local (_1bd3e0294da19198)
Success: Done in 0.426s
Executing erpnext.patches.v10_0.recalculate_gross_margin_for_project in site1.local (_1bd3e0294da19198)
Success: Done in 0.089s
Executing erpnext.patches.v11_0.make_job_card in site1.local (_1bd3e0294da19198)
Success: Done in 0.421s
Executing erpnext.patches.v11_0.redesign_healthcare_billing_work_flow in site1.local (_1bd3e0294da19198)
Success: Done in 0.084s
Executing erpnext.patches.v10_0.delete_hub_documents # 12-08-2018 in site1.local (_1bd3e0294da19198)
Success: Done in 1.175s
Executing erpnext.patches.v11_0.rename_healthcare_fields in site1.local (_1bd3e0294da19198)
Success: Done in 3.741s
Executing erpnext.patches.v11_0.add_default_dispatch_notification_template in site1.local (_1bd3e0294da19198)
Success: Done in 0.65s
Executing erpnext.patches.v11_0.add_market_segments in site1.local (_1bd3e0294da19198)
Success: Done in 0.245s
Executing erpnext.patches.v11_0.add_sales_stages in site1.local (_1bd3e0294da19198)
Success: Done in 0.225s
Executing execute:frappe.delete_doc_if_exists(“Page”, “sales-analytics”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.247s
Executing execute:frappe.delete_doc_if_exists(“Page”, “purchase-analytics”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.167s
Executing execute:frappe.delete_doc_if_exists(“Page”, “stock-analytics”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.211s
Executing execute:frappe.delete_doc_if_exists(“Page”, “production-analytics”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.177s
Executing erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01 #2019-04-26 #2019-05-03 in site1.local (_1bd3e0294da19198)
Success: Done in 0.078s
Executing erpnext.patches.v11_0.drop_column_max_days_allowed in site1.local (_1bd3e0294da19198)
Success: Done in 0.107s
Executing erpnext.patches.v10_0.update_user_image_in_employee in site1.local (_1bd3e0294da19198)
Success: Done in 0.089s
Executing erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items in site1.local (_1bd3e0294da19198)
Success: Done in 0.113s
Executing erpnext.patches.v10_0.allow_operators_in_supplier_scorecard in site1.local (_1bd3e0294da19198)
Success: Done in 0.282s
Executing erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 in site1.local (_1bd3e0294da19198)
Success: Done in 0.145s
Executing erpnext.patches.v11_0.update_delivery_trip_status in site1.local (_1bd3e0294da19198)
Success: Done in 0.632s
Executing erpnext.patches.v11_0.set_missing_gst_hsn_code in site1.local (_1bd3e0294da19198)
Success: Done in 0.264s
Executing erpnext.patches.v11_0.rename_bom_wo_fields in site1.local (_1bd3e0294da19198)
Success: Done in 0.165s
Executing erpnext.patches.v12_0.set_default_homepage_type in site1.local (_1bd3e0294da19198)
Success: Done in 0.092s
Executing erpnext.patches.v11_0.rename_additional_salary_component_additional_salary in site1.local (_1bd3e0294da19198)
Success: Done in 0.068s
Executing erpnext.patches.v11_0.renamed_from_to_fields_in_project in site1.local (_1bd3e0294da19198)
Success: Done in 0.079s
Executing erpnext.patches.v11_0.add_permissions_in_gst_settings in site1.local (_1bd3e0294da19198)
Success: Done in 0.08s
Executing erpnext.patches.v11_1.setup_guardian_role in site1.local (_1bd3e0294da19198)
Success: Done in 0.071s
Executing execute:frappe.delete_doc(‘DocType’, ‘Notification Control’) in site1.local (_1bd3e0294da19198)
Success: Done in 0.23s
Executing erpnext.patches.v12_0.set_gst_category in site1.local (_1bd3e0294da19198)
Success: Done in 0.059s
Executing erpnext.patches.v11_0.remove_barcodes_field_from_copy_fields_to_variants in site1.local (_1bd3e0294da19198)
Success: Done in 0.327s
Executing erpnext.patches.v12_0.set_task_status in site1.local (_1bd3e0294da19198)
Success: Done in 0.061s
Executing erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019 in site1.local (_1bd3e0294da19198)
Success: Done in 0.084s
Executing erpnext.patches.v12_0.add_item_name_in_work_orders in site1.local (_1bd3e0294da19198)
Success: Done in 0.083s
Executing erpnext.patches.v12_0.update_pricing_rule_fields in site1.local (_1bd3e0294da19198)
Success: Done in 0.15s
Executing erpnext.patches.v11_1.make_job_card_time_logs in site1.local (_1bd3e0294da19198)
Success: Done in 0.112s
Executing erpnext.patches.v12_0.rename_pricing_rule_child_doctypes in site1.local (_1bd3e0294da19198)
Success: Done in 0.18s
Executing erpnext.patches.v12_0.move_target_distribution_from_parent_to_child in site1.local (_1bd3e0294da19198)
Success: Done in 0.395s
Executing erpnext.patches.v12_0.stock_entry_enhancements in site1.local (_1bd3e0294da19198)
Success: Done in 0.345s
Executing erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 #25-06-2019 in site1.local (_1bd3e0294da19198)
Success: Done in 0.054s
Executing erpnext.patches.v12_0.make_item_manufacturer in site1.local (_1bd3e0294da19198)
Success: Done in 0.056s
Executing erpnext.patches.v12_0.move_item_tax_to_item_tax_template in site1.local (_1bd3e0294da19198)
Success: Done in 17.503s
Executing erpnext.patches.v11_1.set_variant_based_on in site1.local (_1bd3e0294da19198)
Success: Done in 0.089s
Executing erpnext.patches.v11_1.woocommerce_set_creation_user in site1.local (_1bd3e0294da19198)
Success: Done in 0.175s
Executing erpnext.patches.v11_1.set_salary_details_submittable in site1.local (_1bd3e0294da19198)
Success: Done in 0.105s
Executing erpnext.patches.v11_1.rename_depends_on_lwp in site1.local (_1bd3e0294da19198)
Success: Done in 0.261s
Executing execute:frappe.delete_doc(“Report”, “Inactive Items”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.039s
Executing erpnext.patches.v11_1.delete_scheduling_tool in site1.local (_1bd3e0294da19198)
Success: Done in 0.088s
Executing erpnext.patches.v12_0.rename_tolerance_fields in site1.local (_1bd3e0294da19198)
Success: Done in 0.556s
Executing execute:frappe.delete_doc_if_exists(“Page”, “support-analytics”) in site1.local (_1bd3e0294da19198)
Success: Done in 0.18s
Executing erpnext.patches.v12_0.remove_patient_medical_record_page in site1.local (_1bd3e0294da19198)
Success: Done in 0.165s
Executing erpnext.patches.v11_1.move_customer_lead_to_dynamic_column in site1.local (_1bd3e0294da19198)
Success: Done in 0.117s
Executing erpnext.patches.v11_1.set_default_action_for_quality_inspection in site1.local (_1bd3e0294da19198)
Success: Done in 2.381s
Executing erpnext.patches.v11_1.delete_bom_browser in site1.local (_1bd3e0294da19198)
Success: Done in 0.093s
Executing erpnext.patches.v11_1.set_missing_title_for_quotation in site1.local (_1bd3e0294da19198)
Success: Done in 0.134s
Executing erpnext.patches.v11_1.update_bank_transaction_status in site1.local (_1bd3e0294da19198)
Success: Done in 0.167s
Executing erpnext.patches.v11_1.renamed_delayed_item_report in site1.local (_1bd3e0294da19198)
Success: Done in 0.121s
Executing erpnext.patches.v11_1.set_missing_opportunity_from in site1.local (_1bd3e0294da19198)
Success: Done in 0.106s
Executing erpnext.patches.v12_0.set_quotation_status in site1.local (_1bd3e0294da19198)
Success: Done in 0.125s
Executing erpnext.patches.v12_0.set_priority_for_support 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/erpnext/erpnext/patches/v12_0/set_priority_for_support.py”, line 10, in execute
set_priorities_service_level()
File “/home/interra/frappe-bench/apps/erpnext/erpnext/patches/v12_0/set_priority_for_support.py”, line 34, in set_priorities_service_level
service_level_priorities = frappe.get_list(“Service Level”, fields=[“name”, “priority”, “response_time”, “response_time_period”, “resolution_time”, “resolution_time_period”])
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 129, in build_and_run
return frappe.db.sql(query, as_dict=not self.as_list, debug=self.debug, update=self.update)
File “/home/interra/frappe-bench/apps/frappe/frappe/database/database.py”, line 171, in sql
self._cursor.execute(query)
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.InternalError: (1054, “Unknown column ‘priority’ in ‘field list’”)

Thank you for your support.

Thank you! Glad it helped.

Seems like this patch has an issue with the table definition.

Can you try to run

$ bench migrate

and then repeat? If it does not work, temporarily add erpnext.patches.v12_0.set_priority_for_support to the Patch Log, update, then remove the manual entry again

DELETE FROM `tabPatch Log` WHERE `name`= "YOURTEMPID";

Hope this helps.

@lasalesi, thank you so much. You’re awesome! It worked and my upgrade is completed. Thank you so much! I’m most grateful.

1 Like