Altering models in schema tests

34 views
Skip to first unread message

Sanskar Jaiswal

unread,
Dec 24, 2020, 4:32:14 AM12/24/20
to django-d...@googlegroups.com
Hey everyone,

I am not sure if this is the best place to put this, so kindly let me know if I need to shift this somewhere else.

I am working on a patch for ticket #31335. The patch is working, but I am having trouble writing a clean test case for the same. The test involves removing an index on ForiegnKey, renaming the ForeignKey and adding the index back on the same. Since the schema tests involve using the editor directly, it doesn't affect the ModelState, which leads to a bit of a problem. When we alter the ForeignKey field, the column name is changed, while the field name remains the same. This leads to an inconsistent state when I try to add the index back on the renamed ForiegnKey field.
Since, the fields property of `Model._meta` is immutable, is it advisable to use migration operations to update the same?

Cheers
Sanskar
Sent from Mailspring
Reply all
Reply to author
Forward
0 new messages