ソースを参照

Drop unwanted indexes from Communication and fixes for restoring v7 backup on v8 bench (#3112)

version-14
Nabin Hait 8年前
committed by Rushabh Mehta
コミット
ae088d2211
6個のファイルの変更23行の追加7行の削除
  1. +1
    -3
      frappe/core/doctype/communication/communication.py
  2. +1
    -1
      frappe/core/doctype/feedback_trigger/feedback_trigger.py
  3. +2
    -2
      frappe/model/db_schema.py
  4. +1
    -1
      frappe/model/meta.py
  5. +1
    -0
      frappe/patches.txt
  6. +17
    -0
      frappe/patches/v8_0/drop_unwanted_indexes.py

+ 1
- 3
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":


+ 1
- 1
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



+ 2
- 2
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:


+ 1
- 1
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',


+ 1
- 0
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


+ 17
- 0
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

読み込み中…
キャンセル
保存