The procedure followed:
- I took a database from a v11-develop prod deployment and force restored it onto a v12 branch prod bench
- I then update --patch
- During migration, it throws an error during set_priority_for_support.py
Stack
Executing erpnext.patches.v12_0.set_priority_for_support in erp.opnetwork.gg (######)
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/frappe-opn/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
main()
File "/home/frappe-opn/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
click.Group(commands=commands)(prog_name='bench')
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/frappe-opn/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/frappe-opn/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/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/frappe-opn/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/frappe-opn/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File "/home/frappe-opn/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/frappe-opn/frappe-bench/apps/frappe/frappe/migrate.py", line 48, in migrate
frappe.modules.patch_handler.run_all(skip_failing)
File "/home/frappe-opn/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 41, in run_all
run_patch(patch)
File "/home/frappe-opn/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 30, in run_patch
if not run_single(patchmodule = patch):
File "/home/frappe-opn/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 71, in run_single
return execute_patch(patchmodule, method, methodargs)
File "/home/frappe-opn/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 91, in execute_patch
frappe.get_attr(patchmodule.split()[0] + ".execute")()
File "/home/frappe-opn/frappe-bench/apps/erpnext/erpnext/patches/v12_0/set_priority_for_support.py", line 9, in execute
set_priorities_service_level()
File "/home/frappe-opn/frappe-bench/apps/erpnext/erpnext/patches/v12_0/set_priority_for_support.py", line 33, 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/frappe-opn/frappe-bench/apps/frappe/frappe/__init__.py", line 1266, in get_list
return frappe.model.db_query.DatabaseQuery(doctype).execute(None, *args, **kwargs)
File "/home/frappe-opn/frappe-bench/apps/frappe/frappe/model/db_query.py", line 95, in execute
result = self.build_and_run()
File "/home/frappe-opn/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/frappe-opn/frappe-bench/apps/frappe/frappe/database/database.py", line 171, in sql
self._cursor.execute(query)
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute
result = self._query(query)
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query
conn.query(q)
File "/home/frappe-opn/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/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result
result.read()
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read
first_packet = self.connection._read_packet()
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet
packet.check_error()
File "/home/frappe-opn/frappe-bench/env/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/home/frappe-opn/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'")
Offending bit of code
def set_priorities_service_level():
# Migrates "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period" to Child Table
# as a Service Level can have multiple priorities
try:
service_level_priorities = frappe.get_list("Service Level", fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"])
frappe.reload_doc("support", "doctype", "service_level")
frappe.reload_doc("support", "doctype", "support_settings")
frappe.db.set_value('Support Settings', None, 'track_service_level_agreement', 1)
for service_level in service_level_priorities:
if service_level:
doc = frappe.get_doc("Service Level", service_level.name)
if not doc.priorities:
doc.append("priorities", {
"priority": service_level.priority,
"default_priority": 1,
"response_time": service_level.response_time,
"response_time_period": service_level.response_time_period,
"resolution_time": service_level.resolution_time,
"resolution_time_period": service_level.resolution_time_period
})
doc.flags.ignore_validate = True
doc.save(ignore_permissions=True)
except frappe.db.TableMissingError:
frappe.reload_doc("support", "doctype", "service_level")
Specifically this line
service_level_priorities = frappe.get_list("Service Level", fields=["name", "priority", "response_time", "response_time_period", "resolution_time", "resolution_time_period"])
This is due to a mismatch in DB Schema when the patch is run
DB Schema
describe `tabService Level`;
+------------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| name | varchar(140) | NO | PRI | NULL | |
| creation | datetime(6) | YES | | NULL | |
| modified | datetime(6) | YES | MUL | NULL | |
| modified_by | varchar(140) | YES | | NULL | |
| owner | varchar(140) | YES | | NULL | |
| docstatus | int(1) | NO | | 0 | |
| parent | varchar(140) | YES | MUL | NULL | |
| parentfield | varchar(140) | YES | | NULL | |
| parenttype | varchar(140) | YES | | NULL | |
| idx | int(8) | NO | | 0 | |
| holiday_list | varchar(140) | YES | | NULL | |
| service_level | varchar(140) | YES | UNI | NULL | |
| employee_group | varchar(140) | YES | | NULL | |
| default_priority | varchar(140) | YES | | NULL | |
| _user_tags | text | YES | | NULL | |
| _comments | text | YES | | NULL | |
| _assign | text | YES | | NULL | |
| _liked_by | text | YES | | NULL | |
+------------------+--------------+------+-----+---------+-------+
18 rows in set (0.00 sec)
Any assistance would be appreciated!