mirror of
https://github.com/Hopiu/django-watson.git
synced 2026-05-05 04:14:42 +00:00
Not dropping FKs in InnoDB searchentry tables.
This commit is contained in:
parent
48ae7c9d87
commit
ee9951bd4d
1 changed files with 7 additions and 6 deletions
|
|
@ -351,14 +351,15 @@ class MySQLSearchBackend(SearchBackend):
|
|||
def do_install(self):
|
||||
"""Executes the MySQL specific SQL code to install django-watson."""
|
||||
cursor = connection.cursor()
|
||||
# Drop all foreign keys on the watson_searchentry table.
|
||||
cursor.execute("SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = DATABASE() AND TABLE_NAME = 'watson_searchentry' AND CONSTRAINT_TYPE = 'FOREIGN KEY'")
|
||||
for constraint_name, in cursor.fetchall():
|
||||
cursor.execute("ALTER TABLE watson_searchentry DROP FOREIGN KEY {constraint_name}".format(
|
||||
constraint_name = constraint_name,
|
||||
))
|
||||
# Change the storage engine to MyISAM for older MySQL versions.
|
||||
if get_mysql_version(connection) < (5, 6, 0):
|
||||
# Drop all foreign keys on the watson_searchentry table.
|
||||
cursor.execute("SELECT CONSTRAINT_NAME FROM information_schema.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA = DATABASE() AND TABLE_NAME = 'watson_searchentry' AND CONSTRAINT_TYPE = 'FOREIGN KEY'")
|
||||
for constraint_name, in cursor.fetchall():
|
||||
cursor.execute("ALTER TABLE watson_searchentry DROP FOREIGN KEY {constraint_name}".format(
|
||||
constraint_name = constraint_name,
|
||||
))
|
||||
# Change the storage engine.
|
||||
cursor.execute("ALTER TABLE watson_searchentry ENGINE = MyISAM")
|
||||
# Add the full text indexes.
|
||||
cursor.execute("CREATE FULLTEXT INDEX watson_searchentry_fulltext ON watson_searchentry (title, description, content)")
|
||||
|
|
|
|||
Loading…
Reference in a new issue