Ticket #921 (closed defect: wontfix)
Field modification
| Reported by: | theaspect@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | migrations | Version: | 0.7.3 |
| Keywords: | Cc: |
Description
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
Attachments
Change History
comment:2 Changed 21 months ago by andrew
- Status changed from new to infoneeded
- Milestone set to 1.0
comment:3 Changed 21 months 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
- rename old column
- delete old column
- ...
comment:4 Changed 21 months 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.

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).