瀏覽代碼

fix: Check if index exists with specific key_name

version-14
Suraj Shetty 3 年之前
父節點
當前提交
39031d18ed
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. +3
    -3
      frappe/database/mariadb/schema.py
  2. +1
    -1
      frappe/database/schema.py

+ 3
- 3
frappe/database/mariadb/schema.py 查看文件

@@ -69,7 +69,7 @@ class MariaDBTable(DBTable):
if unique_constraint_changed and not col.unique:
unique_index_record = frappe.db.sql("""
SHOW INDEX FROM `{0}`
WHERE Column_name=%s
WHERE Key_name=%s
AND Non_unique=0
""".format(self.table_name), (col.fieldname), as_dict=1)
if unique_index_record:
@@ -79,9 +79,9 @@ class MariaDBTable(DBTable):
if index_constraint_changed and not col.set_index:
index_record = frappe.db.sql("""
SHOW INDEX FROM `{0}`
WHERE Column_name=%s
WHERE Key_name=%s
AND Non_unique=1
""".format(self.table_name), (col.fieldname), as_dict=1)
""".format(self.table_name), (col.fieldname + '_index'), as_dict=1)
if index_record:
drop_index_query.append("DROP INDEX `{}`".format(index_record[0].Key_name))



+ 1
- 1
frappe/database/schema.py 查看文件

@@ -230,7 +230,7 @@ class DbColumn:
self.table.set_default.append(self)

# index should be applied or dropped irrespective of type change
if ((current_def['index'] and not self.set_index and not self.unique)
if ((current_def['index'] and not self.set_index)
or (current_def['unique'] and not self.unique)):
# to drop unique you have to drop index
self.table.drop_index.append(self)


Loading…
取消
儲存