@@ -15,14 +15,33 @@ jsonfield
1515**jsonfield ** is a reusable model field that allows you to store validated JSON, automatically handling
1616serialization to and from the database. To use, add ``jsonfield.JSONField `` to one of your models.
1717
18- **Warning! **
1918
20- Django 3.1 `introduced `_ a native ``JSONField `` that supports all database backends. New projects should
21- preference Django's implemenation to ``jsonfield ``, and existing users should migrate off of this package.
19+ Deprecation & Migration to Django's native ``JSONField ``
20+ --------------------------------------------------------
21+
22+ Django 3.1 `introduced `_ a native ``JSONField `` that supports all database backends. As such, this package is
23+ considered deprecated and will be archived in the future. Existing projects should migrate to Django's implemenation.
2224
2325.. _introduced : https://docs.djangoproject.com/en/stable/releases/3.1/#jsonfield-for-all-supported-database-backends
2426
2527
28+ Migrating from ``jsonfield.JSONField `` to ``models.JSONField `` *should * generally be straightforward. After swapping
29+ field classes, ``python manage.py migrate `` will generate ``AlterField `` operations that should correctly migrate
30+ your field data. However, if this does not work for your case, you will instead need to create a data migration.
31+ The process will roughly look like:
32+
33+ * Rename ``<field> `` to ``old_<field> ``, create migration.
34+ * Add a nullable ``<field> = models.JSONField(null=True, ...) ``, create migration.
35+ * Create an empty migration file, add ``RunPython `` operation that reserializes
36+ the ``old_<field> `` data into the new ``<field> ``.
37+ * Update ``<field> `` to not nullable, delete ``old_<field> ``, create migration.
38+ * Manually combine the operations into a single migration file.
39+
40+ Examples can be found in the `migration-example `_ project.
41+
42+ .. _migration-example : https://github.com/rpkilby/jsonfield/tree/master/migration-example/
43+
44+
2645Installation
2746------------
2847
0 commit comments