django-auditlog/auditlog/migrations
August Raack 2a7fc23b29
Modify `change` field to be a json field. (#407)
* Modify ``change`` field to be a json field.

Storing the object changes as a json is preferred because it allows SQL
queries to access the change values. This work moves the burden of
handling json objects from an implementation of python's json library in
this package and puts it instead onto the ORM. Ultimately, having the
text field store the changes was leaving them less accessible to external
systems and code that is written outside the scope of the django
auditlog.

This change was accomplished by updating the field type on the model and
then removing the JSON dumps invocations on write and JSON loads
invocations on read. Test were updated to assert equality of
dictionaries rather than equality of JSON parsable text.

Separately, it was asserted that postgres will make these changes to
existing data. Therefore, existing postgres installations should update the
type of existing field values without issue.

* Add test coverage for messages exceeding char len

The "Modify change field to be a json field" commit reduced test
coverage on the mixins.py file by 0.03%. The reduction in coverage was
the result of reducing the number of operations required to achieve the
desired state. An additional test was added to increase previously
uncovered code. The net effect is an increase in test case coverage.

* Add line to changelog

Better markdown formatting

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update CHANGELOG text format

More specific language in the improvement section regarding `LogEntry.change`

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update migration to show Django version 4.0

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update CHANGELOG to show breaking change

Running the migration to update the field type of `LogEntry.change` is a breaking change.

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>

* Update serial order of migrations

* Adjust manager method for compatibility

The create log method on the LogEntry manager required an additional
kwarg for a call to create an instance regardless of a change or not.
This felt brittle anyway. The reason it had worked prior to these
changes was that the `change` kwarg was sending a string "null" and
not a None when there were no changes.

Co-authored-by: Hasan Ramezani <hasan.r67@gmail.com>
2022-12-28 09:50:35 +01:00
..
0001_initial.py Add isort and sort orders with isort. 2020-12-06 23:10:18 +01:00
0002_auto_support_long_primary_keys.py Add isort and sort orders with isort. 2020-12-06 23:10:18 +01:00
0003_logentry_remote_addr.py Add isort and sort orders with isort. 2020-12-06 23:10:18 +01:00
0004_logentry_detailed_object_repr.py Drop Django 2.2 support. 2022-05-01 13:48:26 +02:00
0005_logentry_additional_data_verbose_name.py Drop Django 2.2 support. 2022-05-01 13:48:26 +02:00
0006_object_pk_index.py Add black and format files with black. 2020-12-06 23:10:18 +01:00
0007_object_pk_type.py Add black and format files with black. 2020-12-06 23:10:18 +01:00
0008_action_index.py Add a DB index to LogEntry's action field (#236) 2022-01-04 10:06:45 +01:00
0009_alter_logentry_additional_data.py Drop Django 2.2 support. 2022-05-01 13:48:26 +02:00
0010_alter_logentry_timestamp.py Add an index to the timestamp column (#364) 2022-05-31 09:01:13 +02:00
0011_logentry_serialized_data.py Add serialized object field (#412) 2022-08-21 21:45:50 +02:00
0012_add_logentry_action_access.py Added ACCESS action and enabled logging of object accesses (#436) 2022-11-07 08:51:00 +01:00
0013_alter_logentry_timestamp.py feat: Make timestamp in LogEntry overwritable (#478) 2022-12-19 08:43:29 +01:00
0014_logentry_cid.py Added support for Correlation ID 2022-12-23 15:09:32 +01:00
0015_alter_logentry_changes.py Modify `change` field to be a json field. (#407) 2022-12-28 09:50:35 +01:00
__init__.py Clean up project structure 2020-09-07 16:52:32 +02:00