#25521: squashmigrations tries to add foreign keys to removed models
-------------------------------------+-------------------------------------
     Reporter:  keturn               |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Migrations           |                  Version:  1.8
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by timgraham):

 * status:  new => closed
 * resolution:   => needsinfo
 * needs_tests:   => 0
 * needs_better_patch:   => 0
 * needs_docs:   => 0
 * type:  Uncategorized => Cleanup/optimization


Comment:

 I think we'll need more specific steps to reproduce the issue. Here's what
 I tried:

 {{{
 $ python manage.py makemigrations
 Migrations for 'bar':
   0001_initial.py:
     - Create model Bar: class Bar(models.Model): pass
 Migrations for 'foo':
   0001_initial.py:
     - Create model Foo: class Foo(models.Model): pass

 $ python manage.py makemigrations
 Migrations for 'foo':
   0002_foo_bar.py:
     - Add field bar to foo: bar = models.ForeignKey('bar.Bar', null=True,
 blank=True)

 $ python manage.py makemigrations
 Migrations for 'foo':
   0003_remove_foo_bar.py:
     - Remove field bar from foo

 $ python manage.py makemigrations
 Migrations for 'bar':
   0002_delete_bar.py:
     - Delete model Bar

 $ python manage.py squashmigrations foo 0003
 Will squash the following migrations:
  - 0001_initial
  - 0002_foo_bar
  - 0003_remove_foo_bar
 Do you wish to proceed? [yN] y
 Optimizing...
   Optimized from 3 operations to 1 operations.
 Created new squashed migration
 /home/tim/code/mysite/foo/migrations/0001_squashed_0003_remove_foo_bar.py
   You should commit this migration but leave the old ones in place;
   the new migration will be used for new installs. Once you are sure
   all instances of the codebase have applied the migrations you squashed,
   you can delete them.

 $ python manage.py migrate
 Operations to perform:
   Apply all migrations: bar, sessions, auth, admin, contenttypes, polls,
 foo
 Running migrations:
   Rendering model states... DONE
   Applying bar.0001_initial... OK
   Applying bar.0002_delete_bar... OK
   Applying foo.0001_squashed_0003_remove_foo_bar... OK
 }}}

 Tested at a76309f007fff6957f39190b06f8a9055f73130f (Django 1.10.dev).

--
Ticket URL: <https://code.djangoproject.com/ticket/25521#comment:1>
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/064.1dd7a65343bf271abe995597e81bb208%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to