[fix] Preserved text -> jsonb migration for JSONField fields #722#724
Conversation
Historical migrations were updated to use models.TextField instead of models.JSONField for fields originally backed by the third-party jsonfield library. The original jsonfield.fields.JSONField inherited from TextField and stored values as PostgreSQL text. Replacing historical migration definitions with models.JSONField caused Django to interpret the migration transition as JSONField -> JSONField, resulting in a no-op migration and preventing PostgreSQL columns from being converted to jsonb. By preserving the historical field semantics as TextField, Django can correctly detect the transition from text -> jsonb and generate the required ALTER COLUMN ... TYPE jsonb migration SQL during upgrades. Closes #722
📝 WalkthroughWalkthroughThis PR reverts JSONField references back to TextField in four migration file locations. The changes address PostgreSQL schema migration detection by preserving the historical TextField type in migration files, allowing Django to correctly generate Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewThis PR correctly fixes issue #722 by preserving the historical semantics of database migrations. The Problem: The original The Fix: Changing historical migrations to use Files Reviewed (3 files):
This is the correct approach for handling historical migrations in Django when transitioning from a third-party JSONField to Django's native JSONField. Reviewed by kimi-k2.5 · 89,445 tokens |
|
Proposed change log entry: |
Checklist
Reference to Existing Issue
Closes #722
Please open a new issue if there isn't an existing issue yet.
Description of Changes
Historical migrations were updated to use models.TextField instead of models.JSONField for fields originally backed by the third-party jsonfield library.
The original jsonfield.fields.JSONField inherited from TextField and stored values as PostgreSQL text. Replacing historical migration definitions with models.JSONField caused Django to interpret the migration transition as JSONField -> JSONField, resulting in a no-op migration and preventing PostgreSQL columns from being converted to jsonb.
By preserving the historical field semantics as TextField, Django can correctly detect the transition from text -> jsonb and generate the required ALTER COLUMN ... TYPE jsonb migration SQL during upgrades.