Opened 9 years ago
Closed 9 years ago
#26740 closed Bug (duplicate)
"Key column doesn't exist in table" when adding an index field then renaming it in the same migration in MySQL/PostgreSQL
Reported by: | Gagaro | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
From what I gathered, the index is created at the end of the migration, however the field no longer exists under the same name.
To replicate:
Configure MySQL in the settings.
migrations:
operations = [ migrations.CreateModel( name='TestModel', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ], ), migrations.AddField('testmodel', 'field', models.CharField(db_index=True, default='', max_length=255)), migrations.RenameField('testmodel', 'field', 'field2'), ]
django.db.utils.OperationalError: (1072, "Key column 'field' doesn't exist in table")
Note:
See TracTickets
for help on using tickets.
Duplicate of #25530