views:

41

answers:

1

AFAIK django creates indexes for you in the database (I use MySQL). As these indexes are preventing me from altering column names as part of a south migration I'm performing, I would like to remove these indexes.

Is it legitimate to manually erase django indexes?
Will django recreate them?

+1  A: 

I guess you are altering a unique_together constraint that is stored as an index, in mysql.

And, no django doesn't create it if you delete it, on the fly.

If you delete it manually, you need to create the relevant one, manually as well.

You can see the one that should be created, by ./manage.py sqlall appname

Update (based on your comments):

Jonathan, you are saying that you are trying to migrate.

So, I guess you have already changed the model, and the index that is existing in the db is the one generated in an earlier state of models, at which your syncdb was executed;

Also note that mysql stores unique_together constraints as indexes, and so it adds relevant indexes even without you (or django in this case) having to explicitly ask for it.

Lakshman Prasad
Prasad - Just to make sure, this is a Many2ManyField table which is seperate from both model tables. the indexes have the following names, are these indeed unique_together constraints?appname_mymodel1_mymodel2_mymodel1_id_2950ff45_uniq ...and...appname_mymodel1_mymodel2_19d6ac0c
Jonathan
@Prasad - Also, searching the output of the sqlall command you suggested, I could not find the specific indexes. How come there's a mismatch between the indexes in the db and the indexes in the sqlall output?
Jonathan
@Prasad - I'm accepting your answer, although I still don't understand how to handle this. I may open an additional more focused question now that I have your input.
Jonathan