[fix]: Prevent FallbackMixin from generating spurious migrations #1231#604
[fix]: Prevent FallbackMixin from generating spurious migrations #1231#604shivsubh wants to merge 1 commit intoopenwisp:masterfrom
Conversation
The deconstruct() method was serializing the fallback kwarg into Django migration files. This caused new migrations to be generated whenever the fallback default value changed in settings, even though no actual database schema change had occurred. The fix removes fallback from deconstruct() so Django no longer tracks it as part of the field migration state. fallback is also made optional in __init__ (defaulting to None) so existing migrations that omit the kwarg remain valid. Fixes: #1231
📝 WalkthroughWalkthroughThe changes modify the FallbackMixin class in openwisp_utils/fields.py to address unnecessary migration generation. The fallback argument in Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The deconstruct() method was serializing the fallback kwarg into Django migration files. This caused new migrations to be generated whenever the fallback default value changed in settings, even though no actual database schema change had occurred.
The fix removes fallback from deconstruct() so Django no longer tracks it as part of the field migration state. fallback is also made optional in init (defaulting to None) so existing migrations that omit the kwarg remain valid.
Fixes: openwisp/openwisp-controller#1231
Checklist
Reference to Existing Issue
Closes #.
Please open a new issue if there isn't an existing issue yet.
Description of Changes
Please describe these changes.
Screenshot
Please include any relevant screenshots.