grantmcconnaughey / django-field-history

A Django app to track changes to model fields.
BSD 3-Clause "New" or "Revised" License
314 stars 33 forks source link

How does it handle migrations? #1

Closed grantjenks closed 8 years ago

grantjenks commented 8 years ago

I like your approach to recording model history. I've tried using django-reversion before but it broke as I migrated my models by adding or deleting fields. I wonder, have you considered how django-field-history would handle migrations?

grantmcconnaughey commented 8 years ago

Good question. Most migrations should be handled just fine. The only migration that may cause issues is changing the name of a field that you track with django-field-history. That would mean that:

  1. You'd need to change the field name that you pass into FieldHistoryTracker, i.e. field_history = FieldHistoryTracker(['new_field_name']).
  2. Every FieldHistory row would need its field_name attribute changed to the new field name. This is definitely the bigger issue of the two. I could probably provide a management command to update FieldHistory.field_name based on the FieldHistory.content_type.
grantmcconnaughey commented 8 years ago

Fixed in 2afca6a9ba. I added a management command to update FieldHistory objects after a field name is changed.