Presumably I need a migration in my module to change the implicit
OneToOneField to be a CharField to match, but "makemigrations" doesn't
find any change needed, it's still an integer.
--
Ticket URL: <https://code.djangoproject.com/ticket/25733>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Looking further, some more interesting details arise. If I use
"sqlmigrate", the output does include lines to drop the Speaker
constraint, alter the Speaker's person_ptr_id and putting a constraint
back; but running "migrate" does not include those lines, that constraint
is not dropped and so you get the error I quote above when it tries to
alter Person's ID to a CharField.
However, it actually wouldn't matter if those lines were present, because
running the sqlmigrate output manually, you get a different constraint
failure, the error then changes to be on the same line, but because of
ForeignKey constraints on other models pointing at the Speaker table (ie.
I have a Speech table with a speaker ForeignKey). As well as the direct
constraint, all the constraints associated with the subclass model need to
be dropped first too, it looks like.
So possibly two separate issues: sqlmigrate and migrate not having/running
the same SQL, and not enough constraints being dropped to enable a key to
be changed from implicit to a CharField.
--
Ticket URL: <https://code.djangoproject.com/ticket/25733#comment:1>
Comment (by dracos):
Sorry, the last bit should also mention that the ForeignKeys to the
subclass model (Speaker) need their fields changing to CharField too, that
is missing along with the constraint dropping. Only the subclass model's
field itself appears to be dealt with.
--
Ticket URL: <https://code.djangoproject.com/ticket/25733#comment:2>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/25733#comment:3>
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #25012.
--
Ticket URL: <https://code.djangoproject.com/ticket/25733#comment:4>