diff --git a/docs/releases/3.0.md b/docs/releases/3.0.md index ccab46c1f0..2dd795dfa5 100644 --- a/docs/releases/3.0.md +++ b/docs/releases/3.0.md @@ -238,6 +238,39 @@ The `content_json` field in the `PageRevision` model has been renamed to `conten The `data_json` field in the `BaseLogEntry` model (and its subclasses `PageLogEntry` and `ModelLogEntry`) has been renamed to `data`, and this field now internally uses `JSONField` instead of `TextField`. If you have a large number of objects for these models, running the migrations might take a while. +If you have models that are subclasses of `BaseLogEntry` in your project, be careful when generating new migrations for these models. As the field is changed and renamed at the same time, Django's `makemigrations` command will generate `RemoveField` and `AddField` operations instead of `AlterField` and `RenameField`. To avoid data loss, make sure to adjust the migrations accordingly. For example with a model named `MyCustomLogEntry`, change the following operations: + +```python +operations = [ + migrations.RemoveField( + model_name='mycustomlogentry', + name='data_json', + ), + migrations.AddField( + model_name='mycustomlogentry', + name='data', + field=models.JSONField(blank=True, default=dict), + ), +] +``` + +to the following operations: + +```python +operations = [ + migrations.AlterField( + model_name="mycustomlogentry", + name="data_json", + field=models.JSONField(blank=True, default=dict), + ), + migrations.RenameField( + model_name="mycustomlogentry", + old_name="data_json", + new_name="data", + ), +] +``` + ### Replaced `form_data` `TextField` with `JSONField` in `AbstractFormSubmission` The `form_data` field in the `AbstractFormSubmission` model (and its subclasses `FormSubmission`) has been converted to `JSONField` instead of `TextField`. If you have customisations that programmatically add form submissions you will need to ensure that the `form_data` that is output is no longer a JSON string but instead a serialisable Python object. When interacting with the `form_data` you will now receive a Python object and not a string.