Removing old style migrations... not in use anymore
authorChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 12 Jul 2011 02:09:36 +0000 (21:09 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 12 Jul 2011 02:09:36 +0000 (21:09 -0500)
mediagoblin/db/migrations.py
mediagoblin/db/models.py

index 4cafb1a3cc64a18e4104b66ff0be404a396cb53b..683a57f3b3d47bbaa6ffb7e0d55d55e75878f8a0 100644 (file)
 # 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 mediagoblin.db.util import RegisterMigration
+from mediagoblin.db.util import RegisterMigration
 
-from mongokit import DocumentMigration
-
-
-# This is where the first new-style migration will be written!
-# 
 # Please see mediagoblin/tests/test_migrations.py for some examples of
 # basic migrations.
 
 # @RegisterMigration(1)
 # def do_something(database):
 #     pass
-
-
-class MediaEntryMigration(DocumentMigration):
-    def allmigration01_uploader_to_reference(self):
-        """
-        Old MediaEntry['uploader'] accidentally embedded the User instead
-        of referencing it.  Fix that!
-        """
-        # uploader is an associative array
-        self.target = {'uploader': {'$type': 3}}
-        if not self.status:
-            for doc in self.collection.find(self.target):
-                self.update = {
-                    '$set': {
-                        'uploader': doc['uploader']['_id']}}
-                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},
-                       'description': {'$exists': True}}
-
-        if not self.status:
-            for doc in self.collection.find(self.target):
-                self.update = {
-                    '$set': {
-                        'description_html': cleaned_markdown_conversion(
-                            doc['description'])}}
-        
-class UserMigration(DocumentMigration):
-    def allmigration01_add_bio_and_url_profile(self):
-        """
-        User can elaborate profile with home page and biography
-        """
-        self.target = {'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']
index 279cb9f2bfe5c286698eb38307badec9dd012ebc..918dee0e5c935934e2a863701b1179995fce721b 100644 (file)
 
 import datetime, uuid
 
-from mongokit import Document, Set
+from mongokit import Document
 
 from mediagoblin import util
 from mediagoblin.auth import lib as auth_lib
 from mediagoblin import mg_globals
-from mediagoblin.db import migrations
 from mediagoblin.db.util import ASCENDING, DESCENDING, ObjectId
 
 ###################
@@ -59,8 +58,6 @@ class User(Document):
         'verification_key': lambda: unicode(uuid.uuid4()),
         'is_admin': False}
         
-    migration_handler = migrations.UserMigration
-
     def check_login(self, password):
         """
         See if a user can login with this password
@@ -106,8 +103,6 @@ class MediaEntry(Document):
         'created': datetime.datetime.utcnow,
         'state': u'unprocessed'}
 
-    migration_handler = migrations.MediaEntryMigration
-
     def get_comments(self):
         return self.db.MediaComment.find({
                 'media_entry': self['_id']}).sort('created', DESCENDING)
@@ -196,6 +191,7 @@ class MediaComment(Document):
     def author(self):
         return self.db.User.find_one({'_id': self['author']})
 
+
 REGISTER_MODELS = [
     MediaEntry,
     User,