First migration: Add markdown bio!
authorChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 14 Jul 2011 05:00:24 +0000 (00:00 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 14 Jul 2011 05:00:24 +0000 (00:00 -0500)
mediagoblin/db/migrations.py

index 683a57f3b3d47bbaa6ffb7e0d55d55e75878f8a0..f398f4b34c8b5f899b02f232caa7d4a75abe38bc 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from mediagoblin.db.util import RegisterMigration
+from mediagoblin.util import cleaned_markdown_conversion
+
 
 # Please see mediagoblin/tests/test_migrations.py for some examples of
 # basic migrations.
 
-# @RegisterMigration(1)
-# def do_something(database):
-#     pass
+
+@RegisterMigration(1)
+def user_add_bio_html(database):
+    """
+    Users now have richtext bios via Markdown, reflect appropriately.
+    """
+    collection = database['users']
+
+    target = collection.find(
+        {'bio_html': {'$exists': False}})
+
+    for document in target:
+        document['bio_html'] = cleaned_markdown_conversion(
+            document['bio'])
+        collection.save(document)