#26488: migrate crashes when renaming a multi-table inheritance base model
     Reporter:  Christopher          |                    Owner:  nobody
  Neugebauer                         |
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.9
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0

Comment (by Christopher Neugebauer):

 So here's something fun. Here's how you *can* create a model with a base
 class whose name you can change, and Migrations will be happy.

 1. Create a model `SubModel`, it must derive from `models.Model`.
 2. Create a new base class, `BaseModel`, it must derive from
 3. Add: `basemodel_ptr = OneToOneField(BaseModel, null=True)` on
 `SubModel`. The field *must* be named like the class name of the new base
 4. Automatically create a migration
 5. Create a data migration that creates a new `BaseModel(id=submodel.id)`
 for each `SubModel` instance. This step is only necessary if you have
 created `SubModel` objects. Otherwise, just use an automatic default.
 6. Set the base model of `SubModel` to `BaseModel`
 7. Automatically create a migration
 8. Rename `BaseModel` to `RenamedBaseModel`
 9. Automatically create a migration, accepting the two automatic
 10. Migrate!

 At this point, you can see that `RenamedBaseModel` works as expected. It
 appears as though everything here works, as long as you aren't tracking
 the base class when migrations first creates the model.

Ticket URL: <https://code.djangoproject.com/ticket/26488#comment:8>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to