Bench error - the site stuck at updating :(

altan@ERP:~/frappe-bench$ bench migrate
Migrating site1.local
Executing frappe.patches.v6_9.int_float_not_null in site1.local (1bd3e0294d)
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/altan/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/altan/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/altan/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/altan/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/altan/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/altan/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/altan/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/altan/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/altan/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/altan/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/altan/frappe-bench/apps/frappe/frappe/commands.py”, line 213, in migrate
frappe.modules.patch_handler.run_all()
File “/home/altan/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 25, in run_all
if not run_single(patchmodule = patch):
File “/home/altan/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 52, in run_single
return execute_patch(patchmodule, method, methodargs)
File “/home/altan/frappe-bench/apps/frappe/frappe/modules/patch_handler.py”, line 68, in execute_patch
frappe.get_attr(patchmodule.split()[0] + “.execute”)()
File “/home/altan/frappe-bench/apps/frappe/frappe/patches/v6_9/int_float_not_null.py”, line 16, in execute
.format(doctype=doctype, fieldname=fieldname))
File “/home/altan/frappe-bench/apps/frappe/frappe/database.py”, line 146, in sql
self._cursor.execute(query)
File “/home/altan/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
self.errorhandler(self, exc, value)
File “/home/altan/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.IntegrityError: (1062, “Duplicate entry ‘0’ for key ‘no’”)

@ferohers

You seem to have set a numeric field as unique. This shouldn’t have been allowed by design. We will have to fix this UI bug.

To proceed, run bench --site {yoursite} console.

If ‘no’ is a custom field:

cf = frappe.get_doc("Custom Field", {"fieldname": "no"})
cf.unique = 0
cf.save()

After that, try updating again.

I removed the patches from apps and patch directory then ran bench migrate. All works now but cannot find the field called no.

Console replies -
DoesNotExistError: Özel Alan {u’fieldname’: u’no’} bulunamadı
External access to custom fields

Check any custom doctype for the field ‘no’

I guess I found the criminal

Update was a success after removing the field called “no”