Error in migrate from version 13 to version 14

hello every one
I am trying to migrate from version 13 to version 14.
The switch to Version 15 bench switch-to-branch version-15 frappe erpnext --upgrade was done with no issues.
Then I ran bench --site [YOUR SITE] migrate. This gave me an error in the migration between [‘tabPayment Ledger Entry’, ‘tabGL Entry’].
It ran patches until it reached 85000 records, then gave an error of duplicate key in ‘tabPayment Ledger Entry’.
So I deleted the inserted record in ‘tabPayment Ledger Entry’ and ran migrate again, but still have the same error.

The steps I followed:
a- Installation
1-Installed a new machine with Ubuntu 22.04.4 LTS.
2-Installed ERPNext version 13 manually.
3-Restored my backup, which is also ERPNext version 13.
---------All successful so far ---------
b- Migration from version 13 to version 14

1-cd /path/to/your/frappe-bench
2-curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
3-wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
4-source ~/.bashrc
5-nvm install 18
6-nvm alias default 18
7-bench switch-to-branch version-15 frappe erpnext --upgrade
-------All successful so far ------
8-bench --site [YOUR SITE] migrate
Error in the migration between [‘tabPayment Ledger Entry’, ‘tabGL Entry’].
------------------Error Log
Traceback with variables (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,
mod_name = ‘frappe.utils.bench_helper’
alter_argv = True
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7342326d2bf0>, origin=‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’)
code = <code object at 0x7342317b3cb0, file “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 1>
main_globals = {‘name’: ‘main’, ‘doc’: None, ‘package’: ‘frappe.utils’, ‘loader’: <_frozen_importlib_external.SourceFileLoader object at 0x7342326d2bf0>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7342326d2bf0>, origin=‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’), ‘annotations’: {}, ‘builtins’: <module ‘builtins’ (built-in)>, ‘file’: ‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘cached’: ‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.10/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.10/json/init.py’>, ‘os’: <module ‘os’ from ‘/usr/lib/python3.10/os.py’>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.10/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.10/warni…
File “/usr/lib/python3.10/runpy.py”, line 86, in _run_code
exec(code, run_globals)
code = <code object at 0x7342317b3cb0, file “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 1>
run_globals = {‘name’: ‘main’, ‘doc’: None, ‘package’: ‘frappe.utils’, ‘loader’: <_frozen_importlib_external.SourceFileLoader object at 0x7342326d2bf0>, ‘spec’: ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7342326d2bf0>, origin=’/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’), ‘annotations’: {}, ‘builtins’: <module ‘builtins’ (built-in)>, ‘file’: ‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’, ‘cached’: ‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’, ‘importlib’: <module ‘importlib’ from ‘/usr/lib/python3.10/importlib/init.py’>, ‘json’: <module ‘json’ from ‘/usr/lib/python3.10/json/init.py’>, ‘os’: <module ‘os’ from ‘/usr/lib/python3.10/os.py’>, ‘traceback’: <module ‘traceback’ from ‘/usr/lib/python3.10/traceback.py’>, ‘warnings’: <module ‘warnings’ from ‘/usr/lib/python3.10/warni…
init_globals = None
mod_name = ‘main
mod_spec = ModuleSpec(name=‘frappe.utils.bench_helper’, loader=<_frozen_importlib_external.SourceFileLoader object at 0x7342326d2bf0>, origin=’/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’)
pkg_name = ‘frappe.utils’
script_name = None
loader = <_frozen_importlib_external.SourceFileLoader object at 0x7342326d2bf0>
fname = ‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py’
cached = ‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/pycache/bench_helper.cpython-310.pyc’
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 109, in
main()
…skipped… 25 vars
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=“bench”)
commands = {‘frappe’: , ‘get-frappe-commands’: , ‘get-frappe-help’: }
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
self =
args = ()
kwargs = {‘prog_name’: ‘bench’}
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
self =
args = [‘frappe’, ‘–site’, ‘erp-migration’, ‘migrate’, ‘–skip-failing’]
prog_name = ‘bench’
complete_var = None
standalone_mode = True
extra = {}
ctx = <click.core.Context object at 0x7342317cd4b0>
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x7342317d3250>
args = [‘migrate’, ‘–skip-failing’]
cmd_name = ‘frappe’
cmd =
sub_ctx = <click.core.Context object at 0x734231631ea0>
ctx = <click.core.Context object at 0x7342317cd4b0>
self =
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
_process_result = <function MultiCommand.invoke.._process_result at 0x73423162e710>
args =
cmd_name = ‘migrate’
cmd =
sub_ctx = <click.core.Context object at 0x734231632020>
ctx = <click.core.Context object at 0x734231631ea0>
self =
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
self =
ctx = <click.core.Context object at 0x734231632020>
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
args = ()
kwargs = {‘skip_failing’: True, ‘skip_search_index’: False}
self = <click.core.Context object at 0x734231632020>
callback = <function migrate at 0x7342315deb00>
ctx = <click.core.Context object at 0x734231632020>
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
args = ()
kwargs = {‘skip_failing’: True, ‘skip_search_index’: False}
f = <function migrate at 0x7342315de8c0>
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/commands/init.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
ctx = <click.core.Context object at 0x734231632020>
args = ()
kwargs = {‘skip_failing’: True, ‘skip_search_index’: False}
profile = False
f = <function migrate at 0x7342315de830>
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/commands/site.py”, line 671, in migrate
SiteMigration(
context = {‘sites’: [‘erp-migration’], ‘force’: False, ‘verbose’: False, ‘profile’: False}
skip_failing = True
skip_search_index = False
activate_by_import = <module ‘traceback_with_variables.activate_by_import’ from ‘/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py’>
SiteMigration = <class ‘frappe.migrate.SiteMigration’>
site = ‘erp-migration’
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/migrate.py”, line 182, in run
self.run_schema_updates()
self = <frappe.migrate.SiteMigration object at 0x734231632320>
site = ‘erp-migration’
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/migrate.py”, line 52, in wrapper
raise e
args = (<frappe.migrate.SiteMigration object at 0x734231632320>,)
kwargs = {}
method = <function SiteMigration.run_schema_updates at 0x73422979e950>
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/migrate.py”, line 44, in wrapper
ret = method(*args, **kwargs)
args = (<frappe.migrate.SiteMigration object at 0x734231632320>,)
kwargs = {}
method = <function SiteMigration.run_schema_updates at 0x73422979e950>
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/migrate.py”, line 121, in run_schema_updates
frappe.modules.patch_handler.run_all(
self = <frappe.migrate.SiteMigration object at 0x734231632320>
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 76, in run_all
run_patch(patch)
patch_type = <PatchType.post_model_sync: ‘post_model_sync’>
executed = {‘erpnext.patches.v10_0.set_currency_in_pricing_rule’, ‘execute:frappe.db.set_value(“Accounts Settings”, “Accounts Settings”, “service_provider”, “frankfurter.app”)’, ‘erpnext.patches.v12_0.add_gst_category_in_delivery_note’, ‘frappe.patches.v14_0.setup_likes_from_feedback’, ‘erpnext.patches.v12_0.set_published_in_hub_tracked_item’, ‘erpnext.patches.v11_1.set_status_for_material_request_type_manufacture’, ‘erpnext.patches.v11_0.create_department_records_for_each_company’, ‘erpnext.patches.v13_0.delete_old_purchase_reports’, “execute:frappe.reload_doc(‘custom’, ‘doctype’, ‘custom_field’)”, ‘erpnext.patches.v11_0.skip_user_permission_check_for_department’, ‘erpnext.patches.v13_0.create_accounting_dimensions_for_asset_repair’, ‘frappe.patches.v12_0.remove_feedback_rating’, ‘frappe.patches.v14_0.save_ratings_in_fraction #23-12-2021’, ‘frappe.patches.v15_0.set_file_type’, ‘erpnext.patches.v11_0.rename_asset_adjustment_doctype’, ‘erpnext.patches.v12_0.update_item_tax_template_company’, 'erpn…
run_patch = <function run_all..run_patch at 0x734228952f80>
patches = [“execute:frappe.get_doc(‘Role’, ‘Guest’).save() # remove desk access”, ‘frappe.core.doctype.role.patches.v13_set_default_desk_properties’, ‘frappe.patches.v14_0.update_workspace2 # 06.06.2023’, ‘frappe.patches.v14_0.drop_data_import_legacy’, ‘frappe.patches.v14_0.copy_mail_data #08.03.21’, ‘frappe.patches.v14_0.update_github_endpoints #08-11-2021’, ‘frappe.patches.v14_0.remove_db_aggregation’, ‘frappe.patches.v14_0.update_color_names_in_kanban_board_column’, ‘frappe.patches.v14_0.update_is_system_generated_flag’, ‘frappe.patches.v14_0.update_auto_account_deletion_duration’, ‘frappe.patches.v14_0.update_integration_request’, ‘frappe.patches.v14_0.set_document_expiry_default’, ‘frappe.patches.v14_0.delete_data_migration_tool’, ‘frappe.patches.v14_0.set_suspend_email_queue_default’, ‘frappe.patches.v14_0.different_encryption_key’, ‘frappe.patches.v14_0.update_multistep_webforms’, ‘frappe.patches.v14_0.drop_unused_indexes’, ‘frappe.patches.v14_0.disable_email_accounts_with_oauth’, 'frappe…
patch = ‘erpnext.patches.v14_0.migrate_gl_to_payment_ledger’
skip_failing = True
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 70, in run_patch
update_patch_log(patch, skipped=True)
patch = ‘erpnext.patches.v14_0.migrate_gl_to_payment_ledger’
skip_failing = True
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 210, in update_patch_log
patch = frappe.get_doc({“doctype”: “Patch Log”, “patch”: patchmodule})
patchmodule = ‘erpnext.patches.v14_0.migrate_gl_to_payment_ledger’
skipped = True
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/init.py”, line 1192, in get_doc
doc = frappe.model.document.get_doc(*args, **kwargs)
args = ({‘doctype’: ‘Patch Log’, ‘patch’: ‘erpnext.patches.v14_0.migrate_gl_to_payment_ledger’},)
kwargs = {}
frappe = <module ‘frappe’ from ‘/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/init.py’>
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/model/document.py”, line 73, in get_doc
controller = get_controller(doctype)
args = ({‘doctype’: ‘Patch Log’, ‘patch’: ‘erpnext.patches.v14_0.migrate_gl_to_payment_ledger’},)
kwargs = {‘doctype’: ‘Patch Log’, ‘patch’: ‘erpnext.patches.v14_0.migrate_gl_to_payment_ledger’}
doctype = ‘Patch Log’
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 90, in get_controller
return _get_controller()
_get_controller = <function get_controller.._get_controller at 0x734228953520>
doctype = ‘Patch Log’
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 60, in _get_controller
module_name, custom = frappe.db.get_value(
Document = <class ‘frappe.model.document.Document’>
NestedSet = <class ‘frappe.utils.nestedset.NestedSet’>
doctype = ‘Patch Log’
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/database/database.py”, line 568, in get_value
result = self.get_values(
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x734229747c10>
doctype = ‘DocType’
filters = ‘Patch Log’
fieldname = (‘module’, ‘custom’)
ignore = None
as_dict = False
debug = False
order_by = ‘KEEP_DEFAULT_ORDERING’
cache = False
for_update = False
run = True
pluck = False
distinct = False
skip_locked = False
wait = True
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/database/database.py”, line 672, in get_values
out = self._get_values_from_table(
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x734229747c10>
doctype = ‘DocType’
filters = ‘Patch Log’
fieldname = (‘module’, ‘custom’)
ignore = None
as_dict = False
debug = False
order_by = ‘modified’
update = None
cache = False
for_update = False
run = True
pluck = False
distinct = False
limit = 1
skip_locked = False
wait = True
out = None
fields = (‘module’, ‘custom’)
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/database/database.py”, line 910, in _get_values_from_table
return query.run(as_dict=as_dict, debug=debug, update=update, run=run, pluck=pluck)
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x734229747c10>
fields = (‘module’, ‘custom’)
filters = ‘Patch Log’
doctype = ‘DocType’
as_dict = False
debug = False
order_by = ‘modified’
update = None
for_update = False
skip_locked = False
wait = True
run = True
pluck = False
distinct = False
limit = 1
query = SELECT module,custom FROM tabDocType WHERE name=‘Patch Log’ ORDER BY modified DESC LIMIT 1
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/query_builder/utils.py”, line 87, in execute_query
result = frappe.db.sql(query, params, *args, **kwargs) # nosemgrep
query = ‘SELECT module,custom FROM tabDocType WHERE name=%(param1)s ORDER BY modified DESC LIMIT 1’
args = ()
kwargs = {‘as_dict’: False, ‘debug’: False, ‘update’: None, ‘run’: True, ‘pluck’: False}
child_queries =
params = {‘param1’: ‘Patch Log’}
execute_child_queries = <function patch_query_execute..execute_child_queries at 0x73422979e5f0>
prepare_query = <function patch_query_execute..prepare_query at 0x7342297ac280>
File “/home/m_abdelhameed/frappe-bench/apps/frappe/frappe/database/database.py”, line 244, in sql
self._cursor.execute(query, values)
self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x734229747c10>
query = ‘SELECT module,custom FROM tabDocType WHERE name=%(param1)s ORDER BY modified DESC LIMIT 1’
values = {‘param1’: ‘Patch Log’}
as_dict = False
as_list = 0
formatted = 0
debug = False
ignore_ddl = 0
as_utf8 = 0
auto_commit = 0
update = None
explain = False
run = True
pluck = False
as_iterator = False
trace_id = None
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py”, line 158, in execute
result = self._query(query)
self = <pymysql.cursors.Cursor object at 0x734228baa4a0>
query = “SELECT module,custom FROM tabDocType WHERE name=‘Patch Log’ ORDER BY modified DESC LIMIT 1”
args = {‘param1’: ‘Patch Log’}
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py”, line 325, in _query
conn.query(q)
self = <pymysql.cursors.Cursor object at 0x734228baa4a0>
q = “SELECT module,custom FROM tabDocType WHERE name=‘Patch Log’ ORDER BY modified DESC LIMIT 1”
conn = <pymysql.connections.Connection object at 0x734228baa3e0>
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py”, line 548, in query
self._execute_command(COMMAND.COM_QUERY, sql)
self = <pymysql.connections.Connection object at 0x734228baa3e0>
sql = b"SELECT module,custom FROM tabDocType WHERE name=‘Patch Log’ ORDER BY modified DESC LIMIT 1"
unbuffered = False
File “/home/m_abdelhameed/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py”, line 797, in _execute_command
raise err.InterfaceError(0, “”)
self = <pymysql.connections.Connection object at 0x734228baa3e0>
command = 3
sql = b"SELECT module,custom FROM tabDocType WHERE name=‘Patch Log’ ORDER BY modified DESC LIMIT 1"
pymysql.err.InterfaceError: (0, ‘’)

Hi

try bench --site [yoursite] migrate --skip-failing

i can not use --skip-failing, as it is production enviroment

Does the error itself point to the migration of the field or something else?

This post had a similar error message, I’m not sure the solution would work but the error could have other causes.

https://discuss.frappe.io/t/error-pymysql-err-interfaceerror-0/48034

no the log does not refer to any columns, and I know the tables as it mentioned at the beginning of the batch, the link you post is different as in his case he used docker and i do not use docker i use manual installation

i tray this it fails too