﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25752	RenameField on m2m causes error when new m2m field is added with old name	skyjur	nobody	"When in migrations I do RenameField on ManyToMany field, and then do AddField with ManyToMany with same name but different model, I get Integrity Error referring to existing index. 

It seems the problem is that RenameField does not rename database indexes, and then when new m2m field is being added it tries to create index with same name and so I get database error:

{{{
...
  File ""django/db/backends/utils.py"", line 64, in execute
    return self.cursor.execute(sql, params)
  File ""django/db/utils.py"", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File ""django/db/backends/utils.py"", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation ""cms_test_many_2e06cda4"" already exists
}}}

Here is how migration which creates this error looks like:

{{{
class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.RenameField(
            'test',
            'many',
            'many_legacy',
        ),
        migrations.AddField(
            model_name='test',
            name='many',
            field=models.ManyToManyField(to='cms.NewRel2'),
        ),
    ]

}}}

Initially I noticed this error on 1.7, then I also managed to replicate it on 1.8

Error happened on postgres database."	Uncategorized	new	Migrations	1.8	Normal		postgres migrations renamefield		Unreviewed	0	0	0	0	0	0
