Ticket #921 (closed defect: wontfix)

Opened 4 years ago

Last modified 4 years ago

Field modification

Reported by: theaspect@… Owned by: andrew
Priority: major Milestone: 1.0
Component: migrations Version: 0.7.3
Keywords: Cc:


At first

class MyModel(Model):
    myfield = CharField(u'Field', max_length = 128)

But then
class MyModel?(Model):

myfield = ForeignKey?(MyOtherModel?)

if there any data in myfield, migration brokes on mysql

i thing first myfield shold be deleted or at least renamed with allow null constraint

Change History

comment:1 Changed 4 years ago by andrew

Are you making a ForeignKey to a model which has a CharField as a primary key? If not, that's a type mismatch, and so it's not really a South problem (if you want to delete it and make a new column, then make two migrations for that - you can use --auto for it if you just comment out the field in the middle).

comment:2 Changed 4 years ago by andrew

  • Status changed from new to infoneeded
  • Milestone set to 1.0

comment:3 Changed 4 years ago by theaspect@…

  • Status changed from infoneeded to assigned

Yes, it was second variant. So, south can detect type mismatch in --auto migration, and can propose

  1. rename old column
  2. delete old column
  3. ...

comment:4 Changed 4 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to wontfix

Well, that's just a limitation of the autodetector - if you have a field and you just change the type, the safest (and only) thing it can assume is that you want to alter that column, not delete it and lose all the data. Given that it's really easy to make the autodetector delete it (by commenting it out), I'm marking this WONTFIX.

Note: See TracTickets for help on using tickets.