Last active
November 28, 2020 03:36
-
-
Save erwan-lemonnier/6b777c79aba1d7b1f00d5477246752d6 to your computer and use it in GitHub Desktop.
data migration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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