aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-06-19 20:42:48 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-06-19 20:42:48 -0500
commita01d04a017cbf6009e7122b123aaef7697e299c4 (patch)
tree4c19e44f77d318cd14b434224b4040cdfaca20a8
parent4bf8e8888c7df6717eb43487136cc9d5c155bc6c (diff)
downloadmediagoblin-a01d04a017cbf6009e7122b123aaef7697e299c4.tar.lz
mediagoblin-a01d04a017cbf6009e7122b123aaef7697e299c4.tar.xz
mediagoblin-a01d04a017cbf6009e7122b123aaef7697e299c4.zip
Provide a migration to add description_html to MediaEntries that don't have it
-rw-r--r--mediagoblin/db/migrations.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index f1f625b7..b87988fe 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from mediagoblin.util import cleaned_markdown_conversion
+
from mongokit import DocumentMigration
@@ -33,5 +35,19 @@ class MediaEntryMigration(DocumentMigration):
self.collection.update(
self.target, self.update, multi=True, safe=True)
+ def allmigration02_add_description_html(self):
+ """
+ Now that we can have rich descriptions via Markdown, we should
+ update all existing entries to record the rich description versions.
+ """
+ self.target = {'description_html': {'$exists': False}}
+
+ if not self.status:
+ for doc in self.collection.find(self.target):
+ self.update = {
+ '$set': {
+ 'description_html': cleaned_markdown_conversion(
+ doc['description'])}}
+
MIGRATE_CLASSES = ['MediaEntry']