Changes between Initial Version and Version 2 of Ticket #27860


Ignore:
Timestamp:
Feb 20, 2017, 9:14:43 AM (7 years ago)
Author:
Daniel Quinn
Comment:

alpha.MyOtherModel is using a default numeric key. Sorry, I should have included that in the ticket and so I've modified it to include the MyOtherModel class.

The problem is that migrations is doing an alter for a field that changed not just from a CharField to a ForeignKeyField but rather to a foreign key of a different type. SQLite and MySQL somehow didn't have a problem with this, but PostgreSQL exploded.

Perhaps a solution would be a warning stage not unlike the prompt you get when trying to add a field with no default= value? Something like:

It looks like you've changed a CharField to a ForeignKey of a different type. This will generate an AddField and RemoveField. Is that cool with you?

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27860 – Description

    initial v2  
    2121
    2222{{{
     23class MyOtherModel(models.Model):
     24    stuff = models.CharField(max_length=128)
     25
    2326class MyModel(models.Model):
    2427    my_field = models.ForeignKey("alpha.MyOtherModel", blank=True)
Back to Top