@@ -256,13 +256,11 @@ class Communication(Document): | |||||
frappe.db.commit() | frappe.db.commit() | ||||
def on_doctype_update(): | 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", ["reference_doctype", "reference_name"]) | ||||
frappe.db.add_index("Communication", ["timeline_doctype", "timeline_name"]) | frappe.db.add_index("Communication", ["timeline_doctype", "timeline_name"]) | ||||
frappe.db.add_index("Communication", ["link_doctype", "link_name"]) | frappe.db.add_index("Communication", ["link_doctype", "link_name"]) | ||||
frappe.db.add_index("Communication", ["status", "communication_type"]) | 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): | def has_permission(doc, ptype, user): | ||||
if ptype=="read": | if ptype=="read": | ||||
@@ -33,7 +33,7 @@ def trigger_feedback_request(doc, method): | |||||
def _get(): | def _get(): | ||||
triggers = {} | 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']): | for d in frappe.get_all('Feedback Trigger', dict(enabled=1), ['name', 'document_type']): | ||||
triggers[d.document_type] = d.name | triggers[d.document_type] = d.name | ||||
@@ -307,13 +307,13 @@ class DbTable: | |||||
if not frappe.db.sql("show index from `%s` where key_name = %s" % | if not frappe.db.sql("show index from `%s` where key_name = %s" % | ||||
(self.name, '%s'), col.fieldname): | (self.name, '%s'), col.fieldname): | ||||
query.append("add index `{}`(`{}`)".format(col.fieldname, col.fieldname)) | query.append("add index `{}`(`{}`)".format(col.fieldname, col.fieldname)) | ||||
for col in self.drop_index: | for col in self.drop_index: | ||||
if col.fieldname != 'name': # primary key | if col.fieldname != 'name': # primary key | ||||
# if index key exists | # if index key exists | ||||
if frappe.db.sql("""show index from `{0}` | if frappe.db.sql("""show index from `{0}` | ||||
where key_name=%s | 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)) | query.append("drop index `{}`".format(col.fieldname)) | ||||
for col in self.set_default: | for col in self.set_default: | ||||
@@ -304,7 +304,7 @@ class Meta(Document): | |||||
def set_custom_permissions(self): | def set_custom_permissions(self): | ||||
'''Reset `permissions` with Custom DocPerm if exists''' | '''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 | return | ||||
if not self.istable and self.name not in ('DocType', 'DocField', 'DocPerm', | if not self.istable and self.name not in ('DocType', 'DocField', 'DocPerm', | ||||
@@ -162,6 +162,7 @@ frappe.patches.v7_2.set_doctype_engine | |||||
frappe.patches.v7_2.merge_knowledge_base | frappe.patches.v7_2.merge_knowledge_base | ||||
frappe.patches.v7_0.update_report_builder_json | frappe.patches.v7_0.update_report_builder_json | ||||
frappe.patches.v7_2.set_in_standard_filter_property #1 | 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") | 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.fix_email_queue_recipient | ||||
frappe.patches.v7_2.update_feedback_request # 2017-02-27 | frappe.patches.v7_2.update_feedback_request # 2017-02-27 | ||||
@@ -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 |