Update to v7 fails because 'tabProduction Order Item' table doesn't exist

Hi All,

I’m finally getting around to updating from v6.27.23 to the latest v7 release.

I’m doing some testing upgrades first, and I’m hitting the following problem;

Executing erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items in ship (ship)

bails with the error:
_mysql_exceptions.ProgrammingError: (1146, "Table 'ship.tabProduction Order Item' doesn't exist")

I have a feeling the patches are not executing in the correct order. Anyone else run into this issue?

Thank you,
Jev

Upon digging a little further, looks like this non-existent table was introduced in the following commit:

@nabinhait I think you added this. Would you mind having a look at what is going on here, as far as I can see the upgrade process is currently broken.

Thanks :slight_smile:

Fixed the issue in the latest version.

1 Like

Hi @nabinhait

Thanks for adding a hotfix. I did a quick retest, and it bails on the same item, but now with a new error message.

Stack trace;

Executing erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items in ship (ship)
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, 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/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 700, in __call__
    return self.main(*args, **kwargs)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 680, in main
    rv = self.invoke(ctx)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1027, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1027, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 873, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 508, in invoke
    return callback(*args, **kwargs)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 16, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/commands/site.py", line 209, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/migrate.py", line 30, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/erpnext/frappe-bench/apps/erpnext/erpnext/patches/v7_1/repost_stock_for_deleted_bins_for_merging_items.py", line 35, in execute
    .format(', '.join(['%s']*len(modified_items))), tuple(modified_items)))
  File "/home/erpnext/frappe-bench/apps/frappe/frappe/database.py", line 137, in sql
    self._cursor.execute(query, values)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/erpnext/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, "Unknown column 'pr.source_warehouse' in 'field list'")

Pushed the fix in hotfix, will be merged in master tomorrow.

For now, you can run bench --site <your-site-name> reload-doc manufacturing doctype production_order manually from frappe-bench directory. Then try bench update again.