{{{ things = models.ManyToManyField(Thing, blank=True, null=True) }}}
Django 1.8a1 on my test environment warned me that the {{{blank}}} and
{{{null}}} arguments were unnecessary, so I removed them:
{{{ things = models.ManyToManyField(Thing) }}}
Then I ran {{{manage.py makemigrations}}} and applied the resulting
migration with {{{manage.py migrate}}}. To my horror, the data in the
relevant "linking" table was all deleted.
The section from the migration file looks like this:
{{{
operations = [
migrations.RemoveField(
model_name='group',
name='things',
),
migrations.AddField(
model_name='group',
name='things',
field=models.ManyToManyField(to='sa.Thing'),
),
]
}}}
This doesn't look like the right behaviour to me, and cost me a lot of
time recovering data from backup. Have I done something wrong (other than
trusting the migration file without inspecting it) or is this a genuine
bug?
--
Ticket URL: <https://code.djangoproject.com/ticket/24435>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* severity: Normal => Release blocker
* needs_better_patch: => 0
* needs_tests: => 0
* version: 1.7 => 1.8beta1
* needs_docs: => 0
* stage: Unreviewed => Accepted
Comment:
Seems to be a regression in 1.8 as 1.7 creates a single `AlterField`
operation.
--
Ticket URL: <https://code.djangoproject.com/ticket/24435#comment:1>
* cc: MarkusH (added)
Comment:
Bisected the regression to 623ccdd598625591d1a12fc1564cf3ef9a87581f.
Attaching a regression test.
--
Ticket URL: <https://code.djangoproject.com/ticket/24435#comment:2>
* status: new => assigned
* owner: nobody => MarkusH
--
Ticket URL: <https://code.djangoproject.com/ticket/24435#comment:3>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/4233
--
Ticket URL: <https://code.djangoproject.com/ticket/24435#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/24435#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a9e29fae105d1ddd4e0ac2059cbe62b0ee348bc8"]:
{{{
#!CommitTicketReference repository=""
revision="a9e29fae105d1ddd4e0ac2059cbe62b0ee348bc8"
Fixed #24435 -- Prevented m2m field removal and addition in migrations
when changing blank
Thanks Mark Tranchant for the report an Tim Graham for the test and
review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24435#comment:6>
Comment (by Markus Holtermann <info@…>):
In [changeset:"bff446c205e0c4d436a5147906397ab7534343f3"]:
{{{
#!CommitTicketReference repository=""
revision="bff446c205e0c4d436a5147906397ab7534343f3"
[1.8.x] Fixed #24435 -- Prevented m2m field removal and addition in
migrations when changing blank
Thanks Mark Tranchant for the report and Tim Graham for the test and
review.
Backport of a9e29fae105d1ddd4e0ac2059cbe62b0ee348bc8 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24435#comment:7>