#28684: Removing an index from an IntegerField causes a KeyError exception
-------------------------------------------+---------------------------
Reporter: Daniel Valdivia | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords: migration
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+---------------------------
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'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28684>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/052.89b7e632102008b43342af6fc82d3232%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.