feat: add flag to disable search index rebuild on migrate

This commit is contained in:
Shivam Mishra 2020-06-18 13:34:43 +05:30
parent d2d37a1e04
commit 51b8e467ad
2 changed files with 12 additions and 5 deletions

View file

@ -274,8 +274,9 @@ def disable_user(context, email):
@click.command('migrate')
@click.option('--rebuild-website', help="Rebuild webpages after migration")
@click.option('--skip-failing', is_flag=True, help="Skip patches that fail to run")
@click.option('--skip-search-index', is_flag=True, help="Skip patches that fail to run")
@pass_context
def migrate(context, rebuild_website=False, skip_failing=False):
def migrate(context, rebuild_website=False, skip_failing=False, skip_search_index=False):
"Run patches, sync schema and rebuild files/translations"
from frappe.migrate import migrate
@ -284,7 +285,12 @@ def migrate(context, rebuild_website=False, skip_failing=False):
frappe.init(site=site)
frappe.connect()
try:
migrate(context.verbose, rebuild_website=rebuild_website, skip_failing=skip_failing)
migrate(
context.verbose,
rebuild_website=rebuild_website,
skip_failing=skip_failing,
skip_search_index=skip_search_index
)
finally:
frappe.destroy()
if not context.sites:

View file

@ -23,7 +23,7 @@ from frappe.modules import full_text_search
from frappe.utils import global_search
def migrate(verbose=True, rebuild_website=False, skip_failing=False):
def migrate(verbose=True, rebuild_website=False, skip_failing=False, skip_search_index=False):
'''Migrate all apps to the latest version, will:
- run before migrate hooks
- run patches
@ -82,8 +82,9 @@ Otherwise, check the server logs and ensure that all the required services are r
render.clear_cache()
# add static pages to global search
global_search.update_global_search_for_all_web_pages()
full_text_search.build_index_for_all_routes()
if not skip_search_index:
global_search.update_global_search_for_all_web_pages()
full_text_search.build_index_for_all_routes()
# updating installed applications data
frappe.get_single('Installed Applications').update_versions()