Error while migrating site

bench --site site1.local migrate
Migrating site1.local
Updating DocTypes for frappe        : [========================================] 100%
Updating DocTypes for erpnext       : [                                        ] 1%Failed to alter schema using query: ALTER TABLE `tabPurchase Invoice Item` MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null default 0, MODIFY `cgst_amount` decimal(21,9) not null default 0, MODIFY `margin_rate_or_amount` decimal(21,9) not null default 0, MODIFY `sgst_amount` decimal(21,9) not null default 0, MODIFY `base_rate_with_margin` decimal(21,9) not null default 0, MODIFY `cess_amount` decimal(21,9) not null default 0, MODIFY `rejected_qty` decimal(21,9) not null default 0, MODIFY `cess_non_advol_amount` decimal(21,9) not null default 0, MODIFY `net_rate` decimal(21,9) not null default 0, MODIFY `valuation_rate` decimal(21,9) not null default 0, MODIFY `rate` decimal(21,9) not null default 0, MODIFY `sales_incoming_rate` decimal(21,9) not null default 0, MODIFY `discount_amount` decimal(21,9) not null default 0, MODIFY `item_tax_amount` decimal(21,9) not null default 0, MODIFY `landed_cost_voucher_amount` decimal(21,9) not null default 0, MODIFY `rm_supp_cost` decimal(21,9) not null default 0, MODIFY `rate_with_margin` decimal(21,9) not null default 0, MODIFY `price_list_rate` decimal(21,9) not null default 0, MODIFY `received_qty` decimal(21,9) not null default 0, MODIFY `stock_qty` decimal(21,9) not null default 0, MODIFY `qty` decimal(21,9) not null default 0, MODIFY `amount` decimal(21,9) not null default 0


There was an issue while migrating the DocType: Purchase Invoice Item

Queued rebuilding of search index for site1.local

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 0x7437c86cfc70>, origin='/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py')
      code = <code object <module> at 0x7437c75bdc60, file "/home/cerp/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 0x7437c86cfc70>, '__spec__': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7437c86cfc70>, origin='/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'), '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': '/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py', '__cached__': '/home/cerp/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/warnings.py'>, 'Path': <class 'p...
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
      code = <code object <module> at 0x7437c75bdc60, file "/home/cerp/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 0x7437c86cfc70>, '__spec__': ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7437c86cfc70>, origin='/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'), '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': '/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py', '__cached__': '/home/cerp/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/warnings.py'>, 'Path': <class 'p...
      init_globals = None
      mod_name = '__main__'
      mod_spec = ModuleSpec(name='frappe.utils.bench_helper', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7437c86cfc70>, origin='/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py')
      pkg_name = 'frappe.utils'
      script_name = None
      loader = <_frozen_importlib_external.SourceFileLoader object at 0x7437c86cfc70>
      fname = '/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py'
      cached = '/home/cerp/frappe-bench/apps/frappe/frappe/utils/__pycache__/bench_helper.cpython-310.pyc'
  File "/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
      ...skipped... 27 vars
  File "/home/cerp/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
      commands = {'frappe': <Group frappe>, 'get-frappe-commands': <Command get-frappe-commands>, 'get-frappe-help': <Command get-frappe-help>}
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
      self = <Group None>
      args = ()
      kwargs = {'prog_name': 'bench'}
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
      self = <Group None>
      args = ['frappe', '--site', 'site1.local', 'migrate']
      prog_name = 'bench'
      complete_var = None
      standalone_mode = True
      windows_expand_args = True
      extra = {}
      ctx = <click.core.Context object at 0x7437c75c2ad0>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
      _process_result = <function MultiCommand.invoke.<locals>._process_result at 0x7437c75e7520>
      args = ['migrate']
      cmd_name = 'frappe'
      cmd = <Group frappe>
      sub_ctx = <click.core.Context object at 0x7437c6f174c0>
      ctx = <click.core.Context object at 0x7437c75c2ad0>
      self = <Group None>
      __class__ = <class 'click.core.MultiCommand'>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
      _process_result = <function MultiCommand.invoke.<locals>._process_result at 0x7437c6f1e9e0>
      args = []
      cmd_name = 'migrate'
      cmd = <Command migrate>
      sub_ctx = <click.core.Context object at 0x7437c6f17910>
      ctx = <click.core.Context object at 0x7437c6f174c0>
      self = <Group frappe>
      __class__ = <class 'click.core.MultiCommand'>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
      self = <Command migrate>
      ctx = <click.core.Context object at 0x7437c6f17910>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
      _Context__self = <click.core.Context object at 0x7437c6f17910>
      _Context__callback = <function migrate at 0x7437c7613130>
      args = ()
      kwargs = {'skip_failing': False, 'skip_search_index': False}
      ctx = <click.core.Context object at 0x7437c6f17910>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
      args = ()
      kwargs = {'skip_failing': False, 'skip_search_index': False}
      f = <function migrate at 0x7437c7612ef0>
  File "/home/cerp/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 0x7437c6f17910>
      args = ()
      kwargs = {'skip_failing': False, 'skip_search_index': False}
      profile = False
      f = <function migrate at 0x7437c7612e60>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/commands/site.py", line 613, in migrate
    SiteMigration(
      context = {'sites': ['site1.local'], 'force': False, 'verbose': False, 'profile': False}
      skip_failing = False
      skip_search_index = False
      activate_by_import = <module 'traceback_with_variables.activate_by_import' from '/home/cerp/frappe-bench/env/lib/python3.10/site-packages/traceback_with_variables/activate_by_import.py'>
      SiteMigration = <class 'frappe.migrate.SiteMigration'>
      site = 'site1.local'
  File "/home/cerp/frappe-bench/apps/frappe/frappe/migrate.py", line 190, in run
    self.run_schema_updates()
      self = <frappe.migrate.SiteMigration object at 0x7437c6f17a30>
      site = 'site1.local'
      filelock = <function filelock at 0x7437a5ff12d0>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/migrate.py", line 53, in wrapper
    raise e
      args = (<frappe.migrate.SiteMigration object at 0x7437c6f17a30>,)
      kwargs = {}
      method = <function SiteMigration.run_schema_updates at 0x7437a5ff0ee0>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/migrate.py", line 45, in wrapper
    ret = method(*args, **kwargs)
      args = (<frappe.migrate.SiteMigration object at 0x7437c6f17a30>,)
      kwargs = {}
      method = <function SiteMigration.run_schema_updates at 0x7437a5ff0ee0>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/migrate.py", line 121, in run_schema_updates
    frappe.model.sync.sync_all()
      self = <frappe.migrate.SiteMigration object at 0x7437c6f17a30>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/sync.py", line 43, in sync_all
    sync_for(app, force, reset_permissions=reset_permissions)
      force = 0
      reset_permissions = False
      app = 'erpnext'
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/sync.py", line 111, in sync_for
    import_file_by_path(
      app_name = 'erpnext'
      force = 0
      reset_permissions = False
      files = ['/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/pos_invoice/pos_invoice.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/bank_account/bank_account.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/ledger_merge_accounts/ledger_merge_accounts.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/psoa_cost_center/psoa_cost_center.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/customer_group_item/customer_group_item.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/opening_invoice_creation_tool_item/opening_invoice_creation_tool_item.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/tax_withholding_rate/tax_withholding_rate.json', '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category....
      module_name = 'subcontracting'
      folder = '/home/cerp/frappe-bench/apps/erpnext/erpnext/subcontracting'
      l = 824
      i = 15
      doc_path = '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json'
  File "/home/cerp/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 146, in import_file_by_path
    import_doc(
      path = '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json'
      force = 0
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = False
      docs = [{'actions': [], 'autoname': 'hash', 'creation': '2013-05-22 12:43:10', 'doctype': 'DocType', 'document_type': 'Document', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'bold': 1, 'columns': 3, 'fieldname': 'item_code', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Item', 'oldfieldname': 'item_code', 'oldfieldtype': 'Link', 'options': 'Item', 'print_hide': 1, 'search_index': 1, 'doctype': 'DocField'}, {'fieldname': 'product_bundle', 'fieldtype': 'Link', 'label': 'Product Bundle', 'options': 'Product Bundle', 'read_only': 1, 'doctype': 'DocField'}, {'fieldname': 'col_break1', 'fieldtype': 'Column Break', 'doctype': 'DocField'}, {'fetch_from': 'item_code.item_name', 'fetch_if_empty': 1, 'fieldname': 'item_name', 'fieldtype': 'Data', 'in_global_search': 1, 'label': 'Item Name', 'oldfieldname': 'item_name', 'oldfieldtype': 'Data', 'reqd': 1, 'doctype': 'DocField'}, {'collapsible': 1, 'fieldname': 'description_section', 'fieldtype': 'Section Break', 'label': 'Description', 'doctyp...
      calculated_hash = '4e73cc83c58be9e58819936879d71ca3'
      doc = {'actions': [], 'autoname': 'hash', 'creation': '2013-05-22 12:43:10', 'doctype': 'DocType', 'document_type': 'Document', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'bold': 1, 'columns': 3, 'fieldname': 'item_code', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Item', 'oldfieldname': 'item_code', 'oldfieldtype': 'Link', 'options': 'Item', 'print_hide': 1, 'search_index': 1, 'doctype': 'DocField'}, {'fieldname': 'product_bundle', 'fieldtype': 'Link', 'label': 'Product Bundle', 'options': 'Product Bundle', 'read_only': 1, 'doctype': 'DocField'}, {'fieldname': 'col_break1', 'fieldtype': 'Column Break', 'doctype': 'DocField'}, {'fetch_from': 'item_code.item_name', 'fetch_if_empty': 1, 'fieldname': 'item_name', 'fieldtype': 'Data', 'in_global_search': 1, 'label': 'Item Name', 'oldfieldname': 'item_name', 'oldfieldtype': 'Data', 'reqd': 1, 'doctype': 'DocField'}, {'collapsible': 1, 'fieldname': 'description_section', 'fieldtype': 'Section Break', 'label': 'Description', 'doctype...
      db_modified_timestamp = datetime.datetime(2024, 8, 16, 12, 28, 51, 240236)
      is_db_timestamp_latest = True
      stored_hash = None
  File "/home/cerp/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 239, in import_doc
    doc.insert()
      docdict = {'actions': [], 'autoname': 'hash', 'creation': '2013-05-22 12:43:10', 'doctype': 'DocType', 'document_type': 'Document', 'editable_grid': 1, 'engine': 'InnoDB', 'fields': [{'bold': 1, 'columns': 3, 'fieldname': 'item_code', 'fieldtype': 'Link', 'in_list_view': 1, 'label': 'Item', 'oldfieldname': 'item_code', 'oldfieldtype': 'Link', 'options': 'Item', 'print_hide': 1, 'search_index': 1, 'doctype': 'DocField'}, {'fieldname': 'product_bundle', 'fieldtype': 'Link', 'label': 'Product Bundle', 'options': 'Product Bundle', 'read_only': 1, 'doctype': 'DocField'}, {'fieldname': 'col_break1', 'fieldtype': 'Column Break', 'doctype': 'DocField'}, {'fetch_from': 'item_code.item_name', 'fetch_if_empty': 1, 'fieldname': 'item_name', 'fieldtype': 'Data', 'in_global_search': 1, 'label': 'Item Name', 'oldfieldname': 'item_name', 'oldfieldtype': 'Data', 'reqd': 1, 'doctype': 'DocField'}, {'collapsible': 1, 'fieldname': 'description_section', 'fieldtype': 'Section Break', 'label': 'Description', 'doctype...
      data_import = False
      pre_process = None
      ignore_version = True
      reset_permissions = False
      path = '/home/cerp/frappe-bench/apps/erpnext/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json'
      controller = <class 'frappe.core.doctype.doctype.doctype.DocType'>
      doc = <DocType: Purchase Invoice Item>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/document.py", line 315, in insert
    self.run_post_save_methods()
      self = <DocType: Purchase Invoice Item>
      ignore_permissions = None
      ignore_links = None
      ignore_if_duplicate = False
      ignore_mandatory = None
      set_name = None
      set_child_names = True
      d = <CheckDocField: page_break parent=Purchase Invoice Item>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/document.py", line 1128, in run_post_save_methods
    self.run_method("on_update")
      self = <DocType: Purchase Invoice Item>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
      self = <DocType: Purchase Invoice Item>
      args = ()
      kwargs = {}
      fn = <function Document.run_method.<locals>.fn at 0x7437c640fe20>
      method = 'on_update'
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
      self = <DocType: Purchase Invoice Item>
      args = ()
      kwargs = {}
      hooks = [<function build_domain_restriced_doctype_cache at 0x7437c6f7a170>, <function clear_doctype_notifications at 0x7437c5fae320>, <function process_workflow_actions at 0x7437a4c980d0>, <function attach_files_to_document at 0x7437c6dd5360>, <function apply at 0x7437a4c9aa70>, <function update_due_date at 0x7437a4c9ab00>, <function apply_permissions_for_non_standard_user_type at 0x7437a4ca8280>, <function run_server_script_for_doc_event at 0x7437c640fd00>]
      method = 'on_update'
      doc_events = {'*': {'on_update': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.core.doctype.file.utils.attach_files_to_document', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date', 'frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type', 'frappe_whatsapp.utils.run_server_script_for_doc_event'], 'after_rename': ['frappe.desk.notifications.clear_doctype_notifications'], 'on_cancel': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions', 'frappe.automation.doctype.assignment_rule.assignment_rule.apply', 'frappe_whatsapp.utils.run_server_script_for_doc_event'], 'on_trash': ['frappe.desk.notifications.clear_doctype_notifications', 'frappe.workflow.doctype.workflow_action.workflow_action.process...
      handler = 'frappe_whatsapp.utils.run_server_script_for_doc_event'
      composed = <function Document.hook.<locals>.compose.<locals>.runner at 0x7437c640fd90>
      compose = <function Document.hook.<locals>.compose at 0x7437c640f520>
      f = <function Document.run_method.<locals>.fn at 0x7437c640fe20>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
      self = <DocType: Purchase Invoice Item>
      method = 'on_update'
      args = ()
      kwargs = {}
      add_to_return_value = <function Document.hook.<locals>.add_to_return_value at 0x7437c640f490>
      fn = <function Document.run_method.<locals>.fn at 0x7437c640fe20>
      hooks = (<function build_domain_restriced_doctype_cache at 0x7437c6f7a170>, <function clear_doctype_notifications at 0x7437c5fae320>, <function process_workflow_actions at 0x7437a4c980d0>, <function attach_files_to_document at 0x7437c6dd5360>, <function apply at 0x7437a4c9aa70>, <function update_due_date at 0x7437a4c9ab00>, <function apply_permissions_for_non_standard_user_type at 0x7437a4ca8280>, <function run_server_script_for_doc_event at 0x7437c640fd00>)
  File "/home/cerp/frappe-bench/apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
      self = <DocType: Purchase Invoice Item>
      args = ()
      kwargs = {}
      method_object = <bound method DocType.on_update of <DocType: Purchase Invoice Item>>
      method = 'on_update'
  File "/home/cerp/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 511, in on_update
    raise e
      self = <DocType: Purchase Invoice Item>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 508, in on_update
    frappe.db.updatedb(self.name, Meta(self))
      self = <DocType: Purchase Invoice Item>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 443, in updatedb
    db_table.sync()
      self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7437a5390ac0>
      doctype = 'Purchase Invoice Item'
      meta = <Meta: Purchase Invoice Item>
      res = ((0,),)

Error show while migrating site after bench update How to resolve this error

      db_table = <frappe.database.mariadb.schema.MariaDBTable object at 0x7437a4e23550>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/database/schema.py", line 44, in sync
    self.alter()
      self = <frappe.database.mariadb.schema.MariaDBTable object at 0x7437a4e23550>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/database/mariadb/schema.py", line 111, in alter
    frappe.db.sql_ddl(query)
      col = <frappe.database.schema.DbColumn object at 0x7437a4cb8190>
      add_column_query = []
      columns_to_modify = {<frappe.database.schema.DbColumn object at 0x7437a4c9f010>, <frappe.database.schema.DbColumn object at 0x7437a4c9f040>, <frappe.database.schema.DbColumn object at 0x7437a4c9f0a0>, <frappe.database.schema.DbColumn object at 0x7437a4cb80a0>, <frappe.database.schema.DbColumn object at 0x7437a4cb80d0>, <frappe.database.schema.DbColumn object at 0x7437a4c9f100>, <frappe.database.schema.DbColumn object at 0x7437a4c9f130>, <frappe.database.schema.DbColumn object at 0x7437a4c9f160>, <frappe.database.schema.DbColumn object at 0x7437a4c9f190>, <frappe.database.schema.DbColumn object at 0x7437a4c9f1c0>, <frappe.database.schema.DbColumn object at 0x7437a4c9f1f0>, <frappe.database.schema.DbColumn object at 0x7437a4c9f220>, <frappe.database.schema.DbColumn object at 0x7437a4c9ea40>, <frappe.database.schema.DbColumn object at 0x7437a4c9f250>, <frappe.database.schema.DbColumn object at 0x7437a4c9ea70>, <frappe.database.schema.DbColumn object at 0x7437a4c9f280>, <frappe.database.schema.DbColumn object...
      modify_column_query = ['MODIFY `base_rate` decimal(21,9) not null default 0', 'MODIFY `base_amount` decimal(21,9) not null default 0', 'MODIFY `stock_uom_rate` decimal(21,9) not null default 0', 'MODIFY `weight_per_unit` decimal(21,9) not null default 0', 'MODIFY `total_weight` decimal(21,9) not null default 0', 'MODIFY `base_net_amount` decimal(21,9) not null default 0', 'MODIFY `igst_rate` decimal(21,9) not null default 0', 'MODIFY `taxable_value` decimal(21,9) not null default 0', 'MODIFY `base_net_rate` decimal(21,9) not null default 0', 'MODIFY `net_amount` decimal(21,9) not null default 0', 'MODIFY `cgst_rate` decimal(21,9) not null default 0', 'MODIFY `sgst_rate` decimal(21,9) not null default 0', 'MODIFY `base_price_list_rate` decimal(21,9) not null default 0', 'MODIFY `cess_rate` decimal(21,9) not null default 0', 'MODIFY `discount_percentage` decimal(21,9) not null default 0', 'MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0', 'MODIFY `igst_amount` decimal(21,9) not null default 0', ...
      add_index_query = []
      drop_index_query = []
      query_parts = ['MODIFY `base_rate` decimal(21,9) not null default 0', 'MODIFY `base_amount` decimal(21,9) not null default 0', 'MODIFY `stock_uom_rate` decimal(21,9) not null default 0', 'MODIFY `weight_per_unit` decimal(21,9) not null default 0', 'MODIFY `total_weight` decimal(21,9) not null default 0', 'MODIFY `base_net_amount` decimal(21,9) not null default 0', 'MODIFY `igst_rate` decimal(21,9) not null default 0', 'MODIFY `taxable_value` decimal(21,9) not null default 0', 'MODIFY `base_net_rate` decimal(21,9) not null default 0', 'MODIFY `net_amount` decimal(21,9) not null default 0', 'MODIFY `cgst_rate` decimal(21,9) not null default 0', 'MODIFY `sgst_rate` decimal(21,9) not null default 0', 'MODIFY `base_price_list_rate` decimal(21,9) not null default 0', 'MODIFY `cess_rate` decimal(21,9) not null default 0', 'MODIFY `discount_percentage` decimal(21,9) not null default 0', 'MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0', 'MODIFY `igst_amount` decimal(21,9) not null default 0', ...
      query_body = 'MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null default 0, MODIFY `cgst_amount` decimal(21,9)...
      query = 'ALTER TABLE `tabPurchase Invoice Item` MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null defaul...
      self = <frappe.database.mariadb.schema.MariaDBTable object at 0x7437a4e23550>
  File "/home/cerp/frappe-bench/apps/frappe/frappe/database/database.py", line 417, in sql_ddl
    self.sql(query, debug=debug)
      self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7437a5390ac0>
      query = 'ALTER TABLE `tabPurchase Invoice Item` MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null defaul...
      debug = False
  File "/home/cerp/frappe-bench/apps/frappe/frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
      self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7437a5390ac0>
      query = 'ALTER TABLE `tabPurchase Invoice Item` MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null defaul...
      values = None
      as_dict = 0
      as_list = 0
      debug = False
      ignore_ddl = 0
      auto_commit = 0
      update = None
      explain = False
      run = True
      pluck = False
      as_iterator = False
      trace_id = None
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
      self = <pymysql.cursors.Cursor object at 0x7437a5392410>
      query = 'ALTER TABLE `tabPurchase Invoice Item` MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null defaul...
      args = None
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
      self = <pymysql.cursors.Cursor object at 0x7437a5392410>
      q = 'ALTER TABLE `tabPurchase Invoice Item` MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null defaul...
      conn = <pymysql.connections.Connection object at 0x7437a5392200>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 563, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
      self = <pymysql.connections.Connection object at 0x7437a5392200>
      sql = b'ALTER TABLE `tabPurchase Invoice Item` MODIFY `base_rate` decimal(21,9) not null default 0, MODIFY `base_amount` decimal(21,9) not null default 0, MODIFY `stock_uom_rate` decimal(21,9) not null default 0, MODIFY `weight_per_unit` decimal(21,9) not null default 0, MODIFY `total_weight` decimal(21,9) not null default 0, MODIFY `base_net_amount` decimal(21,9) not null default 0, MODIFY `igst_rate` decimal(21,9) not null default 0, MODIFY `taxable_value` decimal(21,9) not null default 0, MODIFY `base_net_rate` decimal(21,9) not null default 0, MODIFY `net_amount` decimal(21,9) not null default 0, MODIFY `cgst_rate` decimal(21,9) not null default 0, MODIFY `sgst_rate` decimal(21,9) not null default 0, MODIFY `base_price_list_rate` decimal(21,9) not null default 0, MODIFY `cess_rate` decimal(21,9) not null default 0, MODIFY `discount_percentage` decimal(21,9) not null default 0, MODIFY `cess_non_advol_rate` decimal(21,9) not null default 0, MODIFY `igst_amount` decimal(21,9) not null defau...
      unbuffered = False
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 825, in _read_query_result
    result.read()
      self = <pymysql.connections.Connection object at 0x7437a5392200>
      unbuffered = False
      result = <pymysql.connections.MySQLResult object at 0x7437a4dc5f00>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 1199, in read
    first_packet = self.connection._read_packet()
      self = <pymysql.connections.MySQLResult object at 0x7437a4dc5f00>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_packet
    packet.raise_for_error()
      self = <pymysql.connections.Connection object at 0x7437a5392200>
      packet_type = <class 'pymysql.protocol.MysqlPacket'>
      buff = bytearray(b"\xff\x1e\x04#42S22Unknown column \'sales_incoming_rate\' in \'tabPurchase Invoice Item\'")
      packet_header = b'K\x00\x00\x01'
      btrl = 75
      btrh = 0
      packet_number = 1
      bytes_to_read = 75
      recv_data = b"\xff\x1e\x04#42S22Unknown column 'sales_incoming_rate' in 'tabPurchase Invoice Item'"
      packet = <pymysql.protocol.MysqlPacket object at 0x7437a4cb8280>
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
      self = <pymysql.protocol.MysqlPacket object at 0x7437a4cb8280>
      errno = 1054
  File "/home/cerp/frappe-bench/env/lib/python3.10/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
      data = b"\xff\x1e\x04#42S22Unknown column 'sales_incoming_rate' in 'tabPurchase Invoice Item'"
      errno = 1054
      errval = "Unknown column 'sales_incoming_rate' in 'tabPurchase Invoice Item'"
      errorclass = <class 'pymysql.err.OperationalError'>
pymysql.err.OperationalError: (1054, "Unknown column 'sales_incoming_rate' in 'tabPurchase Invoice Item'")

Hi,

May we know if this is a new installation and the first time bench has been updated?

No. i have updated many times

Have there been any customizations made to any doctypes or forms prior to the update? Is so, how were they done?

I have done customization with custom fields, But after customization i have update many times.

@nilpatel42 u can check the purchase invoice item table one field value is set as null so throw the error so check database table of purchase invoice item

1 Like

I have two site with same customization and i have restore same backup on both site, another site migrate is working, only showing error in this site. both have same data also

thank you @Meet