Migrate from v6.X to latest

Hi All,

I’ve been running into a few issues with this installation. So let me breakdown what I tried doing.

The current setup is running inside a ERPNext Production VM. Ubuntu 14 X86 version. I’m trying to move this to a never system with X64 architecture to future proof the system plus to have it on multi-tenant mode as this client currently runs 4x VMs for 4 of their sites.

The new system is Debian 9, and freshly installed and in production mode. I created a site with the same name (erpnext.vm) and imported the DB via MySQL.

Next I ran the following command: bench --site erpnext.vm migrate

This existed multiple times trhowing out an error saying in the lines of table already exists. But each time I ran the command again, it moved on until it hit the next error in similar fashion.

Now however, I am stuck with the following error which would not go away. If you can point me to the right direction in order to correct this, would be much appreciated.

frappe@erpnext:~/frappe-bench$ bench --site erpnext.vm migrate
Migrating erpnext.vm
Executing frappe.patches.v7_2.set_in_standard_filter_property #1 in erpnext.vm (_d56cb677eaab3383)


There was an issue while migrating the DocType: Sales Person

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-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/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-bench/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-bench/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-bench/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-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/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 223, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 39, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v7_2/set_in_standard_filter_property.py", line 13, in execute
    frappe.reload_doctype(doctype.name, force=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 762, in reload_doctype
    force=force, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 774, in reload_doc
    return frappe.modules.reload_doc(module, dt, dn, force=force, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 154, in reload_doc
    return import_files(module, dt, dn, force=force, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 26, in import_files
    reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 31, in import_file
    ret = import_file_by_path(path, force, pre_process=pre_process, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 65, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 133, in import_doc
    doc.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 248, in insert
    self.run_post_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 915, in run_post_save_methods
    self.run_method("on_update")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1058, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1041, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 774, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 258, in on_update
    raise e
pymysql.err.InternalError: (1292, u"Truncated incorrect INTEGER value: 'No'")

Kind Regards,
Asanka

OK, I manage to get past most of the bugs by doing the following on the DB.

UPDATE `tabSales Person` SET `is_group`='1' WHERE `is_group`='Yes';
UPDATE `tabSales Person` SET `is_group`='0' WHERE `is_group`='No';
ALTER TABLE `tabSales Person` MODIFY COLUMN `is_group`  int(1) NULL DEFAULT NULL AFTER `sales_person_name`;


UPDATE `tabTerritory` SET `is_group`='1' WHERE `is_group`='Yes';
UPDATE `tabTerritory` SET `is_group`='0' WHERE `is_group`='No';
ALTER TABLE `tabTerritory` MODIFY COLUMN `is_group`  int(1) NULL DEFAULT NULL AFTER `_assign`;

UPDATE `tabItem Group` SET `is_group`='1' WHERE `is_group`='Yes';
UPDATE `tabItem Group` SET `is_group`='0' WHERE `is_group`='No';
ALTER TABLE `tabItem Group` MODIFY COLUMN `is_group`  int(1) NULL DEFAULT NULL AFTER `_assign`;

UPDATE `tabCustomer Group` SET `is_group`='1' WHERE `is_group`='Yes';
UPDATE `tabCustomer Group` SET `is_group`='0' WHERE `is_group`='No';
ALTER TABLE `tabCustomer Group` MODIFY COLUMN `is_group`  int(1) NULL DEFAULT NULL AFTER `_assign`;

ALTER TABLE `__Auth` ADD COLUMN `salt`  varchar(255) NULL DEFAULT NULL AFTER `encrypted`;

However I’m now stuck here:

Executing erpnext.patches.v7_0.create_warehouse_nestedset in erpnext.vm (_d56cb677eaab3383)
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-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/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-bench/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-bench/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-bench/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-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/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 223, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 39, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_0/create_warehouse_nestedset.py", line 30, in execute
    make_warehouse_nestedset(company)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_0/create_warehouse_nestedset.py", line 74, in make_warehouse_nestedset
    set_parent_to_warehouse(warehouse_group, company)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_0/create_warehouse_nestedset.py", line 111, in set_parent_to_warehouse
    """,(warehouse_group, company.name if company else ""))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 154, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 516, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 727, in _read_query_result
    result.read()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1066, in read
    first_packet = self.connection._read_packet()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 683, in _read_packet
    packet.check_error()
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.InternalError: (1292, u"Truncated incorrect DOUBLE value: ''")

Ok, managed bypass this error by changing the following SQL statement

frappe.db.sql(""" update tabWarehouse set parent_warehouse = %s, is_group = 0
		where (is_group = 0 or is_group is null or is_group = '') and ifnull(company, '') = %s
		""",(warehouse_group, company.name if company else ""))

to:

frappe.db.sql(""" update tabWarehouse set parent_warehouse = %s, is_group = 0
		where is_group = 0)

Now I’m getting this error:

frappe@erpnext:~/frappe-bench$ bench --site erpnext.vm migrate
Migrating erpnext.vm
Executing erpnext.patches.v7_0.remove_features_setup in erpnext.vm (_d56cb677eaab3383)
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-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/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-bench/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-bench/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-bench/env/local/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-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/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 223, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 39, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/patches/v7_0/remove_features_setup.py", line 14, in execute
    create_compact_item_print_custom_field()
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/setup/install.py", line 62, in create_compact_item_print_custom_field
    'insert_after': 'with_letterhead'
  File "/home/frappe/frappe-bench/apps/frappe/frappe/custom/doctype/custom_field/custom_field.py", line 113, in create_custom_field
    custom_field.insert()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 248, in insert
    self.run_post_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 915, in run_post_save_methods
    self.run_method("on_update")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1058, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1041, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 774, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/custom/doctype/custom_field/custom_field.py", line 60, in on_update
    validate_fields_for_doctype(self.dt)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 483, in validate_fields_for_doctype
    validate_fields(frappe.get_meta(doctype, cached=False))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 728, in validate_fields
    check_link_table_options(d)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 529, in check_link_table_options
    frappe.throw(_("Options must be a valid DocType for field {0} in row {1}").format(d.label, d.idx))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 339, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 325, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 298, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Options must be a valid DocType for field Print Style in row 21

Hi, I suppose you should create some Print Style document.

INSERT INTO `tabPrint Style`` (print_style_name, css) VALUES (‘Classic’, ‘test’)

and then run migrate command again

Hey @asanka trust you are doing very well

I seem to have a similar issue but this time on Stock Ledger doctype. Any idears how i can fix this ?

Updating DocTypes for erpnext : [========== ] 53%

There was an issue while migrating the DocType: Stock Ledger Entry

Traceback (most recent call last):
File “/usr/lib/python3.8/runpy.py”, line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.8/runpy.py”, line 86, in _run_code
exec(code, run_globals)
File “/home/frappe/clouderp/apps/frappe/frappe/utils/bench_helper.py”, line 99, in
main()
File “/home/frappe/clouderp/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/frappe/clouderp/env/lib/python3.8/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)

File “/home/frappe/clouderp/env/lib/python3.8/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/frappe/clouderp/env/lib/python3.8/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/frappe/clouderp/env/lib/python3.8/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/frappe/clouderp/env/lib/python3.8/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.InternalError: (1292, “Truncated incorrect INTEGER value: ‘No’”)

I think it’s due to this commit https://github.com/frappe/erpnext/pull/18740
This commit mention this one fix: Do not throw error while reloading doctypes by deepeshgarg007 · Pull Request #8290 · frappe/frappe · GitHub
I follow the SQL problem, try to count Stock Ledger Entry as describe
Next update tabStock Ledger Entry set is_cancelled = 0 where is_cancelled = 'No';
It should work, i advice you to verify rows before, and to backup database & bench folder
Sincerely yours,
Martin

1 Like

Hi Matty.

This solution solved this https://discuss.frappe.io/t/unable-to-update-v12-to-v13/65512/24

Thanks