Repository navigation
fix(migrations): prune index_together in PostgresModelState.render (#286) - #299
Open
UsmanGhias wants to merge 1 commit into
Open
UsmanGhias wants to merge 1 commit into
UsmanGhias wants to merge 1 commit into
Conversation
…ectorLabs#286) On Django 5.1+, index_together was removed from allowed Model Meta attributes. When rendering historical model state for partitioned or custom models that still contain index_together in self.options, Django raises a TypeError during Options.contribute_to_class. Prune index_together from meta_options before constructing the Meta class, matching upstream Django's ticket #34856 fix for ModelState.render. Add unit test asserting clean rendering of state with index_together. Closes SectorLabs#286
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Django 5.1+,
index_togetherwas removed fromdjango.db.models.options.DEFAULT_NAMES. Django adapted its ownModelState.render(ticket #34856) to pruneindex_togetherbefore constructing theMetaclass, allowing historical migrations containingindex_togetherto render without errors.In
psqlextra,PostgresModelState.render()was constructingMetadirectly from**self.options:When historical migrations for custom or partitioned models still contain
index_togetherin their options, Django 5.1+ throws:Changes
psqlextra/backend/migrations/state/model.py, pruneindex_togetherfrommeta_optionsprior to callingtype("Meta", ...):test_partitioned_model_render_index_togetherintests/test_partitioned_model_state.pyasserting that historical partitioned model state withindex_togetherrenders cleanly without raisingTypeError.Closes #286