diff --git a/frappe/core/doctype/communication/communication.py b/frappe/core/doctype/communication/communication.py index 5a75b612cc..4908a1b66c 100644 --- a/frappe/core/doctype/communication/communication.py +++ b/frappe/core/doctype/communication/communication.py @@ -256,13 +256,11 @@ class Communication(Document): frappe.db.commit() def on_doctype_update(): - """Add index in `tabCommunication` for `(reference_doctype, reference_name)`""" + """Add indexes in `tabCommunication`""" frappe.db.add_index("Communication", ["reference_doctype", "reference_name"]) frappe.db.add_index("Communication", ["timeline_doctype", "timeline_name"]) frappe.db.add_index("Communication", ["link_doctype", "link_name"]) frappe.db.add_index("Communication", ["status", "communication_type"]) - frappe.db.add_index("Communication", ["communication_date"]) - frappe.db.add_index("Communication", ["message_id(200)"]) def has_permission(doc, ptype, user): if ptype=="read": diff --git a/frappe/core/doctype/feedback_trigger/feedback_trigger.py b/frappe/core/doctype/feedback_trigger/feedback_trigger.py index ca653724d1..9a3abc32e7 100644 --- a/frappe/core/doctype/feedback_trigger/feedback_trigger.py +++ b/frappe/core/doctype/feedback_trigger/feedback_trigger.py @@ -33,7 +33,7 @@ def trigger_feedback_request(doc, method): def _get(): triggers = {} - if not frappe.flags.in_migrate: + if not (frappe.flags.in_migrate or frappe.flags.in_install): for d in frappe.get_all('Feedback Trigger', dict(enabled=1), ['name', 'document_type']): triggers[d.document_type] = d.name diff --git a/frappe/model/db_schema.py b/frappe/model/db_schema.py index 6023761bcc..400b873b96 100644 --- a/frappe/model/db_schema.py +++ b/frappe/model/db_schema.py @@ -307,13 +307,13 @@ class DbTable: if not frappe.db.sql("show index from `%s` where key_name = %s" % (self.name, '%s'), col.fieldname): query.append("add index `{}`(`{}`)".format(col.fieldname, col.fieldname)) - + for col in self.drop_index: if col.fieldname != 'name': # primary key # if index key exists if frappe.db.sql("""show index from `{0}` where key_name=%s - and Non_unique=%s""".format(self.name), (col.fieldname, 1 if col.unique else 0)): + and Non_unique=%s""".format(self.name), (col.fieldname, 0 if col.unique else 1)): query.append("drop index `{}`".format(col.fieldname)) for col in self.set_default: diff --git a/frappe/model/meta.py b/frappe/model/meta.py index 23513beea5..f1a4916cd3 100644 --- a/frappe/model/meta.py +++ b/frappe/model/meta.py @@ -304,7 +304,7 @@ class Meta(Document): def set_custom_permissions(self): '''Reset `permissions` with Custom DocPerm if exists''' - if frappe.flags.in_patch or frappe.flags.in_import: + if frappe.flags.in_patch or frappe.flags.in_import or frappe.flags.in_install: return if not self.istable and self.name not in ('DocType', 'DocField', 'DocPerm', diff --git a/frappe/patches.txt b/frappe/patches.txt index b44cdc6f9f..d4a4966040 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -162,6 +162,7 @@ frappe.patches.v7_2.set_doctype_engine frappe.patches.v7_2.merge_knowledge_base frappe.patches.v7_0.update_report_builder_json frappe.patches.v7_2.set_in_standard_filter_property #1 +frappe.patches.v8_0.drop_unwanted_indexes execute:frappe.db.sql("update tabCommunication set communication_date = creation where time(communication_date) = 0") frappe.patches.v7_2.fix_email_queue_recipient frappe.patches.v7_2.update_feedback_request # 2017-02-27 diff --git a/frappe/patches/v8_0/drop_unwanted_indexes.py b/frappe/patches/v8_0/drop_unwanted_indexes.py new file mode 100644 index 0000000000..fc66ed43fd --- /dev/null +++ b/frappe/patches/v8_0/drop_unwanted_indexes.py @@ -0,0 +1,17 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals +import frappe + +def execute(): + # communication + unwanted_indexes = ["communication_date_index", "message_id_index", "modified_index", + "creation_index", "reference_owner", "communication_date"] + + for k in unwanted_indexes: + try: + frappe.db.sql("drop index {0} on `tabCommunication`".format(k)) + except: + pass \ No newline at end of file