﻿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
28684	Removing an index from an IntegerField causes a KeyError exception	Daniel Valdivia	nobody	"While attempting to remove a `db_index` from a `IntegerField` through a migration the following way



{{{

class Migration(migrations.Migration):

    dependencies = [
        ('chat', '0005_auto_20170518_2103'),
    ]

    operations = [
        migrations.AlterField(
            model_name='channel',
            name='participant_count',
            field=models.IntegerField(blank=True, default=0),
        ),
    ]

}}}


A `KeyError: 'type'` is thrown



{{{
[standard:dpc] === Starting migration
[standard:dpc] Operations to perform:
[standard:dpc]   Apply all migrations: chat
[standard:dpc] Running migrations:
[standard:dpc]   Applying chat.0006_auto_20171005_1800...
Traceback (most recent call last):
  File ""./manage.py"", line 15, in <module>
    execute_from_command_line(sys.argv)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/core/management/__init__.py"", line 364, in execute_from_command_line
    utility.execute()
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/core/management/__init__.py"", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/core/management/base.py"", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/core/management/base.py"", line 330, in execute
    output = self.handle(*args, **options)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django_tenants/management/commands/migrate_schemas.py"", line 63, in handle
    executor.run_migrations(tenants=tenants)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django_tenants/migration_executors/standard.py"", line 15, in run_migrations
    run_migrations(self.args, self.options, self.codename, schema_name)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django_tenants/migration_executors/base.py"", line 30, in run_migrations
    MigrateCommand(stdout=stdout, stderr=stderr).execute(*args, **options)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/core/management/base.py"", line 330, in execute
    output = self.handle(*args, **options)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/core/management/commands/migrate.py"", line 204, in handle
    fake_initial=fake_initial,
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/migrations/executor.py"", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/migrations/executor.py"", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/migrations/executor.py"", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/migrations/migration.py"", line 129, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/migrations/operations/fields.py"", line 216, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/backends/base/schema.py"", line 515, in alter_field
    old_db_params, new_db_params, strict)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/backends/postgresql/schema.py"", line 112, in _alter_field
    new_db_params, strict,
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/backends/base/schema.py"", line 572, in _alter_field
    index_names = self._constraint_names(model, [old_field.column], index=True, type_=Index.suffix)
  File ""/Users/dvaldivia/esdev/django/pyenv/lib/python2.7/site-packages/django/db/backends/base/schema.py"", line 1003, in _constraint_names
    if type_ is not None and infodict['type'] != type_:
KeyError: 'type'

}}}

"	Bug	closed	Migrations	1.11	Normal	needsinfo	migration		Unreviewed	0	0	0	0	0	0
