Remove deprecated fields from models
See original GitHub issueDescription
A few of our storage models have deprecated fields, these should be removed by a one-off job. You can look at #9329 where we removed username
from all the commit log models.
List of deprecated fields
Models that inherit from BaseModel
-
ExpSummaryModel
→translator_ids
@rohitkatlaa -
UserSettingsModel
→gae_user_id
@rohitkatlaa -
UserSubscriptionsModel
→feedback_thread_ids
@YashJipkate -
UserSubscriptionsModel
→activity_ids
@krishita30j
Nodels that inherit from VersionedModel
-
CollectionModel
→nodes
@iramin (#11350) -
CollectionRightsModel
→translator_ids
@iramin (#11350) -
ExplorationModel
→skill_tags
@hardikkat24 -
ExplorationModel
→default_skin
@hardikkat24 -
ExplorationModel
→skin_customizations
@hardikkat24 -
ExplorationRightsModel
→translator_ids
@hardikkat24 -
ExplorationRightsModel
→all_viewer_ids
(it is not shown as deprecated but still contained in some older versions of the model) @hardikkat24
Steps to remove a field from models that inherit from BaseModel
- Remove the field form the storage model code itself.
- Add a migration job to remove the field from already existing models. The one-off job for removing the
username
from commit log models looks like this: https://github.com/oppia/oppia/blob/170bdeae5912ced0abc71257f5b0e5ca98fd1418/core/domain/activity_jobs_one_off.py#L142-L182 - Create a PR and submit the job to be tested on the backup server.
Steps to remove a field from models that inherit from VersionedModel
- Remove the field form the storage model code itself.
- Add a migration job to remove the field from already existing models. The one-off job for removing the
username
from commit log models looks like this: https://github.com/oppia/oppia/blob/170bdeae5912ced0abc71257f5b0e5ca98fd1418/core/domain/activity_jobs_one_off.py#L142-L182 - Add
_reconstitute
method for the model that will ensure that when we revert to older version of the model we properly remove the field so that the model can be loaded._reconstitute
is already implemented for theCollectionRightsModel
andExplorationRightsModel
https://github.com/oppia/oppia/blob/7623cd028d15a6326cac186f673f368dcae30929/core/storage/exploration/gae_models.py#L403-L440 - Create a PR and submit the job to be tested on the backup server.
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
Deprecating fields in django model - Stack Overflow
I'm normalizing a database associated with a Django project and will be moving fields to different tables. As part ...
Read more >django-deprecate-fields - PyPI
This package allows deprecating model fields and allows removing them in a backwards compatible manner.
Read more >3YOURMIND/django-deprecate-fields - GitHub
This package allows deprecating model fields and allows removing them in a backwards compatible manner. - GitHub - 3YOURMIND/django-deprecate-fields: This ...
Read more >Deprecating model field (Deleting model field, but keeping DB ...
I am having some trouble figuring out the best way to remove model fields in Django. If I remove a field from a...
Read more >django-deprecate-fields - Python package - Snyk
This package allows deprecating model fields and allows removing them in a backwards compatible manner. For more information about how to use this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can we update the instructions for removing a field from VersionedModel inheriting classes to use
model.commit()
rather thanmodel.put()
? It seems that theput()
method deliberately throws a NotImplementedError on VersionedModel as defined here:Just thought it may be helpful for new contributors working on similar tasks with VersionedModel
Assigning @sjiang647 to the ExplorationRightsModel model part of the issue. (As per offline discussion)