#36146: Double-squashed migration is omitted from migration plan
-----------------------------+-------------------------------------------
     Reporter:  Jacob Walls  |                     Type:  Bug
       Status:  new          |                Component:  Migrations
      Version:  dev          |                 Severity:  Release blocker
     Keywords:               |             Triage Stage:  Unreviewed
    Has patch:  0            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+-------------------------------------------
 Start with this `models.py` and generate three simple migrations:
 {{{#!python
 from django.db import models

 class A(models.Model):
     foo = models.BooleanField()
 }}}

 {{{
 ./manage.py makemigrations
 }}}

 {{{#!python
 from django.db import models

 class A(models.Model):
     foo = models.BooleanField(default=True)
 }}}

 {{{
 ./manage.py makemigrations
 }}}

 {{{#!python
 from django.db import models

 class A(models.Model):
     foo = models.BooleanField(default=False)
 }}}

 {{{
 ./manage.py makemigrations
 }}}

 Migrate.
 Squash, migrate, double-squash, migrate.
 Migrate back to zero.
 {{{
 ./manage.py migrate
 ./manage.py squashmigrations new 0001 0002
 ./manage.py migrate
 ./manage.py squashmigrations new 0001_initial_squashed 0003
 ./manage.py migrate
 ./manage.py migrate new zero
 }}}

 Now notice the forward plan is missing a migration:
 {{{
 ./manage.py migrate
 Operations to perform:
   Apply all migrations: new
 Running migrations:
   Applying new.0003_alter_a_foo... OK
 }}}

 And reverse migrate fails (failure would have been evident in the last
 step if it hadn't been an SQL noop):
 {{{
 ./manage.py migrate new zero
 Operations to perform:
   Unapply all migrations: new
 Running migrations:
   Rendering model states... DONE
   Unapplying
 
new.0001_initial_squashed_0002_alter_a_foo_squashed_0003_alter_a_foo...Traceback
 (most recent call last):
   File "/Users/jwalls/django/django/db/backends/utils.py", line 103, in
 _execute
     return self.cursor.execute(sql)
            ~~~~~~~~~~~~~~~~~~~^^^^^
 psycopg2.errors.UndefinedTable: table "new_a" does not exist
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36146>
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 view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070194a7fcd69e-6544bdd2-95c1-428c-9871-7a214bf69e66-000000%40eu-central-1.amazonses.com.

Reply via email to