From: Elrond Date: Sat, 17 Mar 2012 21:30:48 +0000 (+0100) Subject: Let convert_mongo_to_sql add Migration Records X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7bf819a99579a3aec2c539305c08759e2c0b39e3;p=mediagoblin.git Let convert_mongo_to_sql add Migration Records The mongosql tool is really dumping directly into the sql database and is trying not to use too much logic that might change later. So this means, it needs to create the migration records on its own! So add a bunch of records with version=0. --- diff --git a/mediagoblin/db/sql/convert.py b/mediagoblin/db/sql/convert.py index dca93f3f..d1492977 100644 --- a/mediagoblin/db/sql/convert.py +++ b/mediagoblin/db/sql/convert.py @@ -20,7 +20,7 @@ from mediagoblin.init import setup_global_and_app_config, setup_database from mediagoblin.db.mongo.util import ObjectId from mediagoblin.db.sql.models import (Base, User, MediaEntry, MediaComment, - Tag, MediaTag, MediaFile, MediaAttachmentFile) + Tag, MediaTag, MediaFile, MediaAttachmentFile, MigrationData) from mediagoblin.media_types.image.models import ImageData from mediagoblin.media_types.video.models import VideoData from mediagoblin.db.sql.open import setup_connection_and_db_from_config as \ @@ -189,6 +189,20 @@ def convert_media_comments(mk_db): session.close() +def convert_add_migration_versions(): + session = Session() + + for name in ("__main__", + "mediagoblin.media_types.image", + "mediagoblin.media_types.video", + ): + m = MigrationData(name=name, version=0) + session.add(m) + + session.commit() + session.close() + + def run_conversion(config_name): global_config, app_config = setup_global_and_app_config(config_name) @@ -209,6 +223,8 @@ def run_conversion(config_name): Session.remove() convert_media_comments(mk_db) Session.remove() + convert_add_migration_versions() + Session.remove() if __name__ == '__main__':