Repository: frappe/frappe
Pull request: fix: Migration failures for version-13 to develop
<img width="963" alt="Screenshot 2022-06-21 at 9 05 04 PM" src="https://user-images.githubusercontent.com/42651287/174841614-57bf4395-3911-4194-995d-a2c0f108e7dd.png">
<img width="944" alt="Screenshot 2022-06-21 at 9 10 10 PM" src="https://user-images.githubusercontent.com/42651287/174841625-ec3c327a-a939-4bce-af95-e6ceb9ed3354.png">



Problem statement:
Migration from version-13 -> develop fails.
I've tested several migrations from `version-13` -> `develop` 

I should pass `skip-failing` so the model will sync. Once model is synced running `bench migrate` this patch will complete.

`frappe.patches.v14_0.update_workspace2`

```
Retrieving Routes                   : [========================================] 100%
Building Index                      : [========================================] 100%
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.8/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 524, in migrate
    SiteMigration(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 172, in run
    self.run_schema_updates()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 40, in wrapper
    ret = method(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 109, in run_schema_updates
    frappe.modules.patch_handler.run_all(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 76, in run_all
    run_patch(patch)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_patch
    if not run_single(patchmodule=patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 151, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 186, in execute_patch
    _patch()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v14_0/update_workspace2.py", line 13, in execute
    update_workspace(doc, seq, content)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v14_0/update_workspace2.py", line 83, in update_workspace
    doc.save(ignore_permissions=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 299, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 349, in _save
    self.update_children()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 381, in update_children
    self.update_child_table(df.fieldname, df)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 395, in update_child_table
    or frappe.get_meta(df.options).is_virtual == 1
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1179, in get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py", line 52, in get_meta
    meta = Meta(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py", line 114, in __init__
    super(Meta, self).__init__("DocType", doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 106, in __init__
    self.load_from_db()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/meta.py", line 119, in load_from_db
    super(Meta, self).load_from_db()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 148, in load_from_db
    frappe.throw(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 512, in throw
    msgprint(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 487, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 439, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.DoesNotExistError: DocType Workspace Quick List not found
```

Hints from issue discussion:

Commit message: Merge branch 'develop' into migration_failures

Patch to review:
diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py
index e834b698d52c..0d46a2b74643 100644
--- a/frappe/core/doctype/doctype/doctype.py
+++ b/frappe/core/doctype/doctype/doctype.py
@@ -1298,7 +1298,7 @@ def check_is_published_field(meta):
 			frappe.throw(_("Is Published Field must be a valid fieldname"), InvalidFieldNameError)
 
 	def check_website_search_field(meta):
-		if not meta.website_search_field:
+		if not meta.get("website_search_field"):
 			return
 
 		if meta.website_search_field not in fieldname_list:
diff --git a/frappe/patches.txt b/frappe/patches.txt
index 66422c7db082..40b5a4c881de 100644
--- a/frappe/patches.txt
+++ b/frappe/patches.txt
@@ -121,7 +121,7 @@ execute:frappe.delete_doc_if_exists('DocType', 'GCalendar Settings')
 frappe.patches.v12_0.remove_example_email_thread_notify
 execute:from frappe.desk.page.setup_wizard.install_fixtures import update_genders;update_genders()
 frappe.patches.v12_0.set_correct_url_in_files
-execute:frappe.reload_doc('core', 'doctype', 'doctype')
+execute:frappe.reload_doc('core', 'doctype', 'doctype') #2022-06-21
 execute:frappe.reload_doc('custom', 'doctype', 'property_setter')
 frappe.patches.v13_0.remove_invalid_options_for_data_fields
 frappe.patches.v13_0.website_theme_custom_scss
@@ -184,6 +184,7 @@ frappe.patches.v13_0.jinja_hook
 frappe.patches.v13_0.update_notification_channel_if_empty
 frappe.patches.v13_0.set_first_day_of_the_week
 execute:frappe.reload_doc('custom', 'doctype', 'custom_field')
+execute:frappe.reload_doc('desk', 'doctype', 'workspace_quick_list')
 frappe.patches.v14_0.update_workspace2 # 20.09.2021
 frappe.patches.v14_0.save_ratings_in_fraction #23-12-2021
 frappe.patches.v14_0.transform_todo_schema


Code review comments:
diff_hunk: @@ -184,6 +184,7 @@ frappe.patches.v13_0.jinja_hook
 frappe.patches.v13_0.update_notification_channel_if_empty
 frappe.patches.v13_0.set_first_day_of_the_week
 execute:frappe.reload_doc('custom', 'doctype', 'custom_field')
+execute:frappe.reload_doc('desk', 'doctype', 'workspace_quick_list')
path: frappe/patches.txt
text: @user2:
There's separate patch for this already `reload_workspace_child_tables` which probably needs to merged with original workspace patch.

@user1 ?