M17-Project / REPEATER

Repeater Entry Provides Extremely Accurate and True Estimates of Range
2 stars 4 forks source link

Database model versioning (DIY or library, your choice!) #5

Open tarxvftech opened 2 years ago

tarxvftech commented 2 years ago

Custom code

Modify the django models so that each instance of a model can refer to old versions of its data, but when investigating properties only the most recent version of the data is returned. As an example - I don't actually know how this one might look, this is a mockup of the style of functionality I'm thinking of to illustrate the value - you might modify the model to support something like this:

>>> firstrepeater = Repeater.objects.all()[0]
>>> firstrepeater.name
"KC1AWV"
>>> firstrepeater.checkpoint() 
>>> firstrepeater.name = "W2FBI"
>>> firstrepeater.save()
>>> firstrepeater.name
"W2FBI"
>>> firstrepeater.previous[0].name
"KC1AWV"

Leave fields in the implementation to store metadata about each change, so a history of changes to the data of a repeater can be displayed. Getting this implementation right might be fairly tricky, or it might even be a bad idea. I admit I'm not sure exactly how I'd go about this.

Integration of a plugin

Alternatively, and much simpler (though maybe a little less fun, right?) implement one of django-simple-history or django-reversion and make sure revisions track which user made the change. Provide some example usage with the Repeater model.