question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove deprecated fields from models

See original GitHub issue

Description

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

Nodels that inherit from VersionedModel

  • CollectionModelnodes @iramin (#11350)
  • CollectionRightsModeltranslator_ids @iramin (#11350)
  • ExplorationModelskill_tags @hardikkat24
  • ExplorationModeldefault_skin @hardikkat24
  • ExplorationModelskin_customizations @hardikkat24
  • ExplorationRightsModeltranslator_ids @hardikkat24
  • ExplorationRightsModelall_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

  1. Remove the field form the storage model code itself.
  2. 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
  3. 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

  1. Remove the field form the storage model code itself.
  2. 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
  3. 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 the CollectionRightsModel and ExplorationRightsModel https://github.com/oppia/oppia/blob/7623cd028d15a6326cac186f673f368dcae30929/core/storage/exploration/gae_models.py#L403-L440
  4. Create a PR and submit the job to be tested on the backup server.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
michaelw54commented, Dec 28, 2020

Can we update the instructions for removing a field from VersionedModel inheriting classes to use model.commit() rather than model.put()? It seems that the put() method deliberately throws a NotImplementedError on VersionedModel as defined here:

def put(self, *args, **kwargs):
        """For VersionedModels, this method is replaced with commit()."""
        raise NotImplementedError(
            'The put() method is missing from the '
            'derived class. It should be implemented in the derived class.')

Just thought it may be helpful for new contributors working on similar tasks with VersionedModel

1reaction
DubeySandeepcommented, Dec 26, 2020

Assigning @sjiang647 to the ExplorationRightsModel model part of the issue. (As per offline discussion)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found