NonUniqueError: Item: Field 'Hub Sync ID' cannot be set as Unique

I have been trying to finishing the update to my first ever production instance of ERPNext, which host two custom apps (one for reporting, the other for electronic invoicing both a regionalization feature), and after several snapshot reverts and following proper steps to update from V11 to V12, I have gotten as far as the final migration of DocTypes, until I get the error shown below.

I managed to migrate to python3.6 successfully, switch to the branches properly, and apply the patches. When it gets to migration, I get this:

frappe.core.doctype.doctype.doctype.NonUniqueError: Item: Field 'Hub Sync ID' cannot be set as Unique as it has non-unique values

The entire traceback is below.

I did check my database directly to make sure that the unique field in such custom fields was set to 0 zero, and indeed, I have 4 items in Custom Field with such a value. None were with 1.

I am almost done with my update to v12, but I am stuck. Anyone with suggestions as to what I am missing? My production bench is currently down due to this issue. (I do have snapshots, but wish to complete the process before reverting once work week begins)


[EDIT]: Had tried searching for the error and some forum messages referenced custom_field.json as the culprit. Search and find any field listed in your custom apps with a unique value of 1.
I did find the custom fields in one of the apps, but not the other. It did have a custom field Item-Hub Sync ID with a value of "unique": 1,
I changed it to 0 on that custom field and the other four.
That SOLVED the problem.


Traceback (most recent call last):
  File "/usr/lib/python3.6/", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/", line 85, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 97, in <module>
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 18, in main
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/", line 239, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 52, in migrate
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/", line 24, in sync_fixtures
    ignore_links=True, overwrite=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/data_import/", line 60, in import_doc
    frappe.modules.import_file.import_file_by_path(f, data_import=True, force=True, pre_process=pre_process, reset_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 66, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 141, in import_doc
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 260, in insert
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 924, in run_post_save_methods
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 794, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1064, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1047, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 788, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/custom/doctype/custom_field/", line 61, in on_update
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 670, in validate_fields_for_doctype
    validate_fields(frappe.get_meta(doctype, cached=False))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 971, in validate_fields
    check_unique_and_text(meta.get("name"), d)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 797, in check_unique_and_text
    frappe.throw(_("{0}: Field '{1}' cannot be set as Unique as it has non-unique values").format(docname, d.label), NonUniqueError)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 377, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 356, in msgprint
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 316, in _raise_exception
    raise raise_exception(msg)
frappe.core.doctype.doctype.doctype.NonUniqueError: Item: Field 'Hub Sync ID' cannot be set as Unique as it has non-unique values