From f55c7bcd3e525f33ac560ce0d76f0157fd07c49e Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Wed, 18 Dec 2024 18:56:31 +0530 Subject: [PATCH] fix: On migrate flush everything Press is single-deploy, so this is fine. It's almost equivalent to frappe.clear_cache() --- press/hooks.py | 18 +++++++++++------- press/overrides.py | 5 +++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/press/hooks.py b/press/hooks.py index 34181d90eb..85e006fd93 100644 --- a/press/hooks.py +++ b/press/hooks.py @@ -358,7 +358,7 @@ # These are used for some business logic, they should be manually evicted. -__persistent_cache_keys =[ +__persistent_cache_keys = [ "agent-jobs", "monitor-transactions", "google_oauth_flow*", @@ -373,26 +373,27 @@ # - Adding more keys here will slow down `frappe.clear_cache` but it's "rare" enough. # - This also means that other "valid" frappe.clear_cache() usage won't clear these keys! # - Use frappe.cache.flushall() instead. -persistent_cache_keys = __persistent_cache_keys + [ +persistent_cache_keys = [ + *__persistent_cache_keys, "agent_job_step_output", "all_apps", "app_hooks", "assets_json", "assignment_rule_map", "bootinfo", - "builder.builder*", # path resolution, it has its own cache eviction. + "builder.builder*", # path resolution, it has its own cache eviction. "db_tables", "defaults", "doctype_form_meta", - "doctype_meta" + "doctype_meta", "doctypes_with_web_view", "document_cache::*", "document_naming_rule_map", "domain_restricted_doctypes", "domain_restricted_pages", "energy_point_rule_map", - "frappe.utils.scheduler.schedule_jobs_based_on_activity*", # dormant checks - "frappe.website.page_renderers*", # FW's routing + "frappe.utils.scheduler.schedule_jobs_based_on_activity*", # dormant checks + "frappe.website.page_renderers*", # FW's routing "home_page", "information_schema:counts", "installed_app_modules", @@ -403,9 +404,12 @@ "marketplace_apps", "merged_translations", "metadata_version", - "server_script_map", # Routing and actual server scripts + "server_script_map", # Routing and actual server scripts "session", "table_columns", "website_page", "website_route_rules", ] + +before_migrate = ["press.overrides.before_after_migrate"] +after_migrate = ["press.overrides.before_after_migrate"] diff --git a/press/overrides.py b/press/overrides.py index 6531bcfa0f..4e1f66e19a 100644 --- a/press/overrides.py +++ b/press/overrides.py @@ -195,3 +195,8 @@ def after_rename(self, old_name, new_name, merge=False): WHERE name = %s""", (new_name, new_name), ) + + +def before_after_migrate(): + # frappe.clear_cache() on press doesn't clear everything. See hooks.py + frappe.cache.flushall()