#25012: Migrations don't make foreign key type changes
-------------------------------------+------------------------------------
Reporter: Hedde van der Heide | Owner: (none)
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: migrations | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Simon Charette):
* owner: Simon Charette => (none)
* status: assigned => new
Comment:
I managed to reproduce but I think the issue is specific to `sqlmigrate`
when dealing with cross-app relationships and due to how related models
are lazily built. When using the `migrate` command everything seems to
work fine.
The `alter_field` method relies on `_related_non_m2m_objects` to determine
which models points back at the field being altered but since `sqlmigrate`
only loads the minimal plan it might not render some back referencing
models and thus `_related_non_m2m_objects` won't return them. Unless
someone can reproduce the same issue by solely using `migrate` I think
this issue should be closed as fixed since
[https://github.com/django/django/blob/415f50298f97fb17f841a9df38d995ccf347dfcc/tests/migrations/test_operations.py#L1434-L1494
we already tests for it] and a new one could be opened for `sqlmigrate`
misbehaviour.
I attached a test project I used to reproduce the `sqlmigrate` issue and
confirm `migrate` works fine. Notice that `sqlmigrate app_one 0002`
doesn't mention `app_two_baz_foos` at all unless
`app_one.0002_auto_20210105_2317` is changed to depend on
`app_two.0001_initial` which forces the rendering of the
`app_two.Baz.Baz_Foo` model. I suspect the issue can also be reproduced
using a `ForeignKey` across apps.
--
Ticket URL: <https://code.djangoproject.com/ticket/25012#comment:16>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.ebefe69449eb3f31c20cab05739287af%40djangoproject.com.