WIP: 29177 - ForeignKeys on Unmanaged models get those serialized into migrations#9741
WIP: 29177 - ForeignKeys on Unmanaged models get those serialized into migrations#9741kezabelle wants to merge 1 commit intodjango:masterfrom
Conversation
I'd rely on the fact that
This is more likely due to the lexicographical ordering of models and the followup optimization of operations. Try swapping the model names and you should see the exact opposite behavior. |
There was a problem hiding this comment.
Can you add a similar test case where the FK points to a managed model, please :)
8576f37 to
2423688
Compare
|
Did some tidy-up and added in the extra test |
|
I think I found the explanation for that as well.
So, this is going to be considerably more work :( Though, at the moment, I'm struggling to understand why we need to keep the distinction between concrete, proxy and unmanaged models in the autodetector 🤔 |
|
Thanks for investigating further for me. As a bit of exploration, I've tried removing the code: and from that part of the autodetector, and that does fix the lack of operations for the adding of a FK to existing unmanaged models. It also turns the I don't know that just excising the code would be the correct fix -- as you say, there's a whole built-in distinction for unmanaged models, and it's a bigger ticket than either of us thought -- so I've not pushed the change, but it's interesting. |
|
Closing due to inactivity. |
Trac ticket: https://code.djangoproject.com/ticket/29177
Marking as work in progress because it's just a sketch right now, and will need rebasing & tidying up. I've left comments saying as much in the code, so those at least will need to go :)
Specific questions I have:
AddFieldontest_unmanaged_model_fk_to_managed_modelmight try and do?CreateModel, CreateModel, AddField) than a FK from an unmanaged model to another unmanaged model (CreateModel, CreateModel)?test_adding_an_fk_to_an_unmanaged_model) so that the serialized field is available in subsequent migrations, even if it's a no-op. But it doesn't seem to, given the way I've usedself.get_changes... so maybe I've used it wrong?