Bench Update Error on Custom Doctype

I created a custom Doctype for my requirements, but this doctype screwed up my migration. How can I restore a previous version of my site? I know bench takes 3 backups daily.

Migrating site1.local
Executing frappe.patches.v11_0.apply_customization_to_custom_doctype in site1.local (1bd3e0294da19198)

There was an issue while migrating the DocType: Sampling

Traceback (most recent call last):
  File "/usr/lib/python2.7/", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/", line 72, in _run_code
    exec code in 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/local/lib/python2.7/site-packages/click/", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 717, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/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 227, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/", line 47, in migrate
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v11_0/", line 51, in execute
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 260, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 313, in _save
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 905, in run_post_save_methods
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 772, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1048, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1031, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 766, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/core/doctype/doctype/", line 243, in on_update
    raise e
pymysql.err.InternalError: (1170, u"BLOB/TEXT column 'code' used in key specification without a key length")

You can uninstall the custom app, rerun the update, and then re-install the custom app. You might need to do a bench migrate to synch the DB

I am unable to run Bench Migrate because there seems to be some missing element in my doctype. Is there anyway I can access the doctype through SSH and add the missing data? so that the migration can run?

You can do

bench reload-doctype “Name Of Doctype To Reload”

but I am not sure if that works for custom apps/types

frappe@folder:~/frappe-bench$ bench reload-doctype Sampling
/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/sampling/sampling.json missing

Sampling is my file. Then I go to that folder, and none of my custom Doctypes are there. This happened after today’s update. Is there any way I can delete the custom doctypes from my sistem through ssh and start over? I have alot of other info that I don’t want deleted.

I don’t know that app - I can only guess - maybe the uninstall/reinstall will recreate the necessary tables/data?

Can you point to how can i do this?

I am guessing, but… (as user frappe)

cd ~/frappe-bench
bench --site site1.local uninstall-app Sampling

Same error:
ImportError: No module named Sampling

I think the issue is that the Doctype was created as Sample, and we later changed it to Sampling. Maybe renaming a doctype has a bug and didn’t update the file system (but it did update the database) and this is causing an issue

Thanks everyone for their help, but I think the quickest way to handle this is to create a new site and put the database back in.