#23474: Schema migrations can inadvertently destroy data
-------------------------------+--------------------------------------
     Reporter:  Naddiseo       |                    Owner:  nobody
         Type:  Uncategorized  |                   Status:  new
    Component:  Migrations     |                  Version:  1.7
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by valtron):

 The bug is in
 
https://github.com/django/django/blob/master/django/db/migrations/executor.py#L39-L43.

 The code should be (I think)

 {{{#!python
 next_migration = get_next_migration_in_same_app(target)
 # If `target` is the most recent one in its app, there is nothing to do.
 if next_migration:
     backwards_plan = self.loader.graph.backwards_plan(next_migration)
 }}}

 The reasoning: forwards migrations to app.000X are inclusive; backwards
 migrations to app.000X are exclusive (app.000X isn't actually unapplied).
 The not-unapplying of app.000X is currently handled by the `[:-1]` in line
 39; however, the dependents of app.000X are still unapplied.

 I'll submit a pull request as soon as I figure out how to implement
 `get_next_migration_in_same_app`.

--
Ticket URL: <https://code.djangoproject.com/ticket/23474#comment:2>
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/066.3a40447f778b0120b30d593cf812b777%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to