adds accommmodations for migration of fields in User: bio and url
authorcfdv <caldavis@gmail.com>
Mon, 20 Jun 2011 18:07:15 +0000 (13:07 -0500)
committercfdv <caldavis@gmail.com>
Mon, 20 Jun 2011 18:07:15 +0000 (13:07 -0500)
mediagoblin/db/migrations.py

index b87988fe5e5ba30d9a09612ba67e6cd8a2c978f0..a3e7133ce34f973a4b5b6a2bb22d40d74f059cc7 100644 (file)
@@ -49,5 +49,21 @@ class MediaEntryMigration(DocumentMigration):
                         'description_html': cleaned_markdown_conversion(
                             doc['description'])}}
         
-
-MIGRATE_CLASSES = ['MediaEntry']
+class UserMigration(DocumentMigration):
+    def allmigration01_add_bio_and_url_profile(self):
+        """
+        User can elaborate profile with home page and biography
+        """
+        self.target = {'username': {'$exists': True}, 'url': {'$exists': False},
+                          'bio': {'$exists': False}}
+        if not self.status:
+            for doc in self.collection.find(self.target):
+                self.update = {
+                    '$set': {
+                        'url': '', 
+                        'bio': ''}}
+                self.collection.update(
+                    self.target, self.update, multi=True, safe=True)
+                        
+                        
+MIGRATE_CLASSES = ['MediaEntry','User']