Move from v11 to 13 fails

Hello, all.

I have the working V11 in VM downloaded 2-3 years ago and employed. It has the full db (items, BOMs, suppliers, etc.) and no local changes except one field added to the item document.

I downloaded Ubuntu 20.04 VM and installed the V13 in it - looks as working fine. 
Now, I made backup of V11 bt "bench --site site_name backup" and than restored by "bench --site site_name --force restore /path/to/copied/latest_date_time_sql.gz".
Restoration passed smoothly.
Now, when I rebooted the V13 machine and tried to connect to it, my browser shows "Internal Server error".
Studying logs directory I can see in schedule.log:
    2022-02-15 10:52:01,177 ERROR scheduler Exception in Enqueue Events for Site erpnext.plris.com
    Traceback (most recent call last):
      File "apps/frappe/frappe/utils/scheduler.py", line 67, in enqueue_events_for_site
    enqueue_events(site=site)
      File "apps/frappe/frappe/utils/scheduler.py", line 82, in enqueue_events
    if schedule_jobs_based_on_activity():
      File "apps/frappe/frappe/utils/scheduler.py", line 120, in schedule_jobs_based_on_activity
    if is_dormant(check_time=check_time):
      File "apps/frappe/frappe/utils/scheduler.py", line 138, in is_dormant
    since = (frappe.get_system_settings('dormant_days') or 4) * 86400
      File "apps/frappe/frappe/__init__.py", line 1773, in get_system_settings
    local.system_settings.update({key: db.get_single_value(doctype, key)})
      File "apps/frappe/frappe/database/database.py", line 585, in get_single_value
    frappe.throw(_('Invalid field name: {0}').format(frappe.bold(fieldname)), self.InvalidColumnName)
      File "apps/frappe/frappe/__init__.py", line 445, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
      File "apps/frappe/frappe/__init__.py", line 424, in msgprint
    _raise_exception()
      File "apps/frappe/frappe/__init__.py", line 378, in _raise_exception
    raise raise_exception(msg)
    frappe.database.database.Database.InvalidColumnName: Invalid field name: <b>dormant_days</b>
============
    And in web.error.log I see very similar complains (extract):
      File "/home/leonp/frappe-bench/apps/frappe/frappe/database/database.py", line 933, in get_table_columns
    raise self.TableMissingError('DocType', doctype)
    =============

    As I am very weak in this area, I will be very thankful for any recommendation how to overcome this problem.

Try moving to V12 first. Then if everything is fine go to V13.

I spent about 7-8 days trying to receive the working V13 installation.
Are you sure that going through V12 will solve this issue?

Hello @leonp ,

After your run bench --site site_name restore did you run bench migrate ?

Thank you, @dj12djdjs.
No, I missed this. BUT(!) when I run this command, I received the similar error:

… many patches passed ok …

Executing erpnext.patches.v13_0.patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive in erpnext.plris.com (_7200f4ca41e3b886)

Traceback (most recent call last):
File “/usr/lib/python3.8/runpy.py”, line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.8/runpy.py”, line 87, in _run_code
exec(code, run_globals)
File “/home/leonp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 104, in
main()
File “/home/leonp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 19, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/click/decorators.py”, line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/leonp/frappe-bench/apps/frappe/frappe/commands/init.py”, line 27, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/leonp/frappe-bench/apps/frappe/frappe/commands/site.py”, line 306, in migrate
migrate(
File “/home/leonp/frappe-bench/apps/frappe/frappe/migrate.py”, line 69, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File “/home/leonp/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 41, in run_all
run_patch(patch)
File “/home/leonp/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/leonp/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/leonp/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/leonp/frappe-bench/apps/erpnext/erpnext/patches/v13_0/patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive.py”, line 23, in execute
employee_incentives = frappe.get_all(“Employee Incentive”,
File “/home/leonp/frappe-bench/apps/frappe/frappe/init.py”, line 1475, in get_all
return get_list(doctype, *args, **kwargs)
File “/home/leonp/frappe-bench/apps/frappe/frappe/init.py”, line 1448, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
File “/home/leonp/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 107, in execute
result = self.build_and_run()
File “/home/leonp/frappe-bench/apps/frappe/frappe/model/db_query.py”, line 144, in build_and_run
return frappe.db.sql(query, as_dict=not self.as_list, debug=self.debug,
File “/home/leonp/frappe-bench/apps/frappe/frappe/database/database.py”, line 152, in sql
self._cursor.execute(query)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/cursors.py”, line 148, in execute
result = self._query(query)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/cursors.py”, line 310, in _query
conn.query(q)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 548, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 775, in _read_query_result
result.read()
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 1156, in read
first_packet = self.connection._read_packet()
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/connections.py”, line 725, in _read_packet
packet.raise_for_error()
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/protocol.py”, line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File “/home/leonp/frappe-bench/env/lib/python3.8/site-packages/pymysql/err.py”, line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, “Unknown column ‘additional_salary’ in ‘field list’”)

Thank you, @Muzzy - I tried to follow your advice.
I downloaded the V12 VM and test it - works fine.
Then I did “bench --site myname --force restore” - passed.
Then I did “bench migrate” and received:
Executing frappe.patches.v12_0.set_primary_key_in_series in erpnext.local (_ea106b3e4781622f)
Syntax error in query:
ALTER table tabSeries ADD PRIMARY KEY IF NOT EXISTS (name)
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/ferpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/ferpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/ferpnext/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/ferpnext/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/ferpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/ferpnext/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/ferpnext/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/ferpnext/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/ferpnext/frappe-bench/apps/frappe/frappe/migrate.py”, line 48, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File “/home/ferpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 41, in run_all
run_patch(patch)
File “/home/ferpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 30, in run_patch
if not run_single(patchmodule = patch):
File “/home/ferpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/ferpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/ferpnext/frappe-bench/apps/frappe/frappe/patches/v12_0/set_primary_key_in_series.py”, line 21, in execute
frappe.db.sql(‘ALTER table tabSeries ADD PRIMARY KEY IF NOT EXISTS (name)’)
File “/home/ferpnext/frappe-bench/apps/frappe/frappe/database/database.py”, line 171, in sql
self._cursor.execute(query)
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 170, in execute
result = self._query(query)
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py”, line 328, in _query
conn.query(q)
File “/home/ferpnext/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/ferpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 732, in _read_query_result
result.read()
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 1075, in read
first_packet = self.connection._read_packet()
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py”, line 684, in _read_packet
packet.check_error()
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py”, line 220, in check_error
err.raise_mysql_exception(self._data)
File “/home/ferpnext/frappe-bench/env/lib/python3.6/site-packages/pymysql/err.py”, line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IF NOT EXISTS (name)’ at line 1”)

Looks like it might be a bug. If you check the employee incentive doctype erpnext/employee_incentive.json at version-13 · frappe/erpnext · GitHub there is not field “additional_salary”. This should be raised on ERPNext GitHub issues.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.