#22359 closed Bug (fixed)
Changing m2m field to blank=True makes failed migration on sqlite
Reported by: | Stephen Burrows | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.7-beta-1 |
Severity: | Release blocker | Keywords: | |
Cc: | Stephen Burrows, adrien, loic@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If I change a M2M field by adding blank=True, the migration that django creates fails on SQLite. Specifically, it tries to re-create the M2M table (even though it already exists.)
I find this especially strange since adding blank=True to an M2M field actually doesn't change the database structure at all.
Migration file:
# encoding: utf8 from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('brambling', '0021_auto_20140330_1917'), ] operations = [ migrations.AlterField( model_name='person', name='event_types', field=models.ManyToManyField(to='brambling.EventType', blank=True), ), migrations.AlterField( model_name='person', name='dance_styles', field=models.ManyToManyField(to='brambling.DanceStyle', blank=True), ), ]
Traceback:
File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File ".../django/django/core/management/__init__.py", line 427, in execute_from_command_line utility.execute() File ".../django/django/core/management/__init__.py", line 419, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File ".../django/django/core/management/base.py", line 288, in run_from_argv self.execute(*args, **options.__dict__) File ".../django/django/core/management/base.py", line 337, in execute output = self.handle(*args, **options) File ".../django/django/core/management/commands/migrate.py", line 145, in handle executor.migrate(targets, plan, fake=options.get("fake", False)) File ".../django/django/db/migrations/executor.py", line 60, in migrate self.apply_migration(migration, fake=fake) File ".../django/django/db/migrations/executor.py", line 94, in apply_migration migration.apply(project_state, schema_editor) File ".../django/django/db/migrations/migration.py", line 97, in apply operation.database_forwards(self.app_label, schema_editor, project_state, new_state) File ".../django/django/db/migrations/operations/fields.py", line 130, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File ".../django/django/db/backends/sqlite3/schema.py", line 143, in alter_field return self._alter_many_to_many(model, old_field, new_field, strict) File ".../django/django/db/backends/sqlite3/schema.py", line 168, in _alter_many_to_many self.create_model(new_field.rel.through) File ".../django/django/db/backends/schema.py", line 253, in create_model self.execute(sql, params) File ".../django/django/db/backends/schema.py", line 95, in execute cursor.execute(sql, params) File ".../django/django/db/backends/utils.py", line 77, in execute return super(CursorDebugWrapper, self).execute(sql, params) File ".../django/django/db/backends/utils.py", line 61, in execute return self.cursor.execute(sql, params) File ".../django/django/db/utils.py", line 94, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File ".../django/django/db/backends/utils.py", line 61, in execute return self.cursor.execute(sql, params) File ".../django/django/db/backends/sqlite3/base.py", line 479, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: table "brambling_person_event_types" already exists
Change History (5)
comment:1 by , 11 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version 0, edited 11 years ago by (next)
comment:2 by , 11 years ago
Cc: | added |
---|---|
Severity: | Normal → Release blocker |
comment:3 by , 11 years ago
Has patch: | set |
---|
@melinath, @adrien, could you please check if https://github.com/django/django/pull/2499 solves your problem?
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I'm able to reproduce.