diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-02-18 10:01:47 -0600 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2012-02-18 10:01:47 -0600 |
commit | 63352aaf70d97a37b6277fab0f9b957d34dcb9df (patch) | |
tree | acdedffc204d89f1f71f09696270e5719f5e3123 /mediagoblin/db/mongo/migrations.py | |
parent | 7f3ec607a34e727324397c2bf240f771b12a0455 (diff) | |
parent | feba5c5287a7cb4c0ed8f5124ad60a8a291770ad (diff) | |
download | mediagoblin-63352aaf70d97a37b6277fab0f9b957d34dcb9df.tar.lz mediagoblin-63352aaf70d97a37b6277fab0f9b957d34dcb9df.tar.xz mediagoblin-63352aaf70d97a37b6277fab0f9b957d34dcb9df.zip |
Merge branch 'master' into sqlmigrate
Conflicts:
mediagoblin/db/sql/models.py
Diffstat (limited to 'mediagoblin/db/mongo/migrations.py')
-rw-r--r-- | mediagoblin/db/mongo/migrations.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/mediagoblin/db/mongo/migrations.py b/mediagoblin/db/mongo/migrations.py index 168fa530..59035f3b 100644 --- a/mediagoblin/db/mongo/migrations.py +++ b/mediagoblin/db/mongo/migrations.py @@ -1,5 +1,5 @@ # GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS. +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -29,6 +29,16 @@ def add_table_field(db, table_name, field_name, default_value): multi=True) +def drop_table_field(db, table_name, field_name): + """ + Drop an old field from a table/collection + """ + db[table_name].update( + {field_name: {'$exists': True}}, + {'$unset': {field_name: 1}}, + multi=True) + + # Please see mediagoblin/tests/test_migrations.py for some examples of # basic migrations. @@ -115,3 +125,17 @@ def mediaentry_add_license(database): Add the 'license' field for entries that don't have it. """ add_table_field(database, 'media_entries', 'license', None) + + +@RegisterMigration(9) +def remove_calculated_html(database): + """ + Drop pre-rendered html again and calculate things + on the fly (and cache): + - User.bio_html + - MediaEntry.description_html + - MediaComment.content_html + """ + drop_table_field(database, 'users', 'bio_html') + drop_table_field(database, 'media_entries', 'description_html') + drop_table_field(database, 'media_comments', 'content_html') |