Skip to content

Instantly share code, notes, and snippets.

@erwan-lemonnier
Last active November 28, 2020 03:36
Show Gist options
  • Save erwan-lemonnier/6b777c79aba1d7b1f00d5477246752d6 to your computer and use it in GitHub Desktop.
Save erwan-lemonnier/6b777c79aba1d7b1f00d5477246752d6 to your computer and use it in GitHub Desktop.
data migration
class Message():
def normalize(self):
# If message lacks a 'likes' counter, initialize one
if not hasattr(self, 'count_likes'):
self.count_likes = 0
# Each time you are fetching a message from datastore, do
# something like:
msg = fetch_from_database(message_id)
msg.normalize()
msg.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment