Ok, ho trovato alcune informazioni qui https://docs.djangoproject.com/en/1.8/_modules/django/db/backends/base/schema/#BaseDatabaseSchemaEditor.alter_field
E ho creato un manuale RunPython
migrazione per eliminare varchar_pattern_ops
indice utilizzando l'SchemaEditor
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import re
def drop_md5hash_varchar_pattern_ops_index(apps, schemaEditor):
# code based on https://docs.djangoproject.com/en/1.8/_modules/django/db/backends/base/schema/#BaseDatabaseSchemaEditor.alter_field
model = apps.get_model("logger", "Btilog")
index_names = schemaEditor._constraint_names(model, index=True)
for index_name in index_names:
if re.search('logger_btilog_md5hash_.+_like', index_name):
print 'dropping index {}'.format(index_name)
schemaEditor.execute(schemaEditor._delete_constraint_sql(schemaEditor.sql_delete_index, model, index_name))
class Migration(migrations.Migration):
dependencies = [
('logger', '0012_auto_20150529_1745'),
]
operations = [
# Remove the annoying index using a hack
migrations.RunPython(
drop_md5hash_varchar_pattern_ops_index
),
]