Added the actual fake/testing migrations. Haven't run them yet...

This commit is contained in:
Christopher Allan Webber 2011-07-10 16:19:49 -05:00
parent d0ee0003a2
commit 77ffe9be58

View File

@ -17,6 +17,7 @@
from pymongo import Connection from pymongo import Connection
from mediagoblin.tests.tools import install_fixtures_simple
from mediagoblin.db.util import RegisterMigration, MigrationManager from mediagoblin.db.util import RegisterMigration, MigrationManager
# This one will get filled with local migrations # This one will get filled with local migrations
@ -39,7 +40,9 @@ def creature_add_magical_powers(database):
This defaults to [], an empty list. Since we haven't declared any This defaults to [], an empty list. Since we haven't declared any
magical powers, all existing monsters should magical powers, all existing monsters should
""" """
pass database['creatures'].update(
{'magical_powers': {'$exists': False}},
{'$set': {'magical_powers': []}})
@RegisterMigration(2, TEST_MIGRATION_REGISTRY) @RegisterMigration(2, TEST_MIGRATION_REGISTRY)
@ -49,7 +52,9 @@ def creature_rename_num_legs_to_num_limbs(database):
just how many legs. We don't care about the ambiguous distinction just how many legs. We don't care about the ambiguous distinction
between arms/legs currently. between arms/legs currently.
""" """
pass database['creatures'].update(
{'num_legs': {'$exists': True}},
{'$rename': {'num_legs': 'num_limbs'}})
@RegisterMigration(3, TEST_MIGRATION_REGISTRY) @RegisterMigration(3, TEST_MIGRATION_REGISTRY)
@ -58,7 +63,9 @@ def creature_remove_is_demon(database):
It turns out we don't care much about whether creatures are demons It turns out we don't care much about whether creatures are demons
or not. or not.
""" """
pass database['creatures'].update(
{'is_demon': {'$exists': True}},
{'$unset': {'is_demon': 1}})
@RegisterMigration(4, TEST_MIGRATION_REGISTRY) @RegisterMigration(4, TEST_MIGRATION_REGISTRY)
@ -78,7 +85,18 @@ def level_exits_dict_to_list(database):
{'name': 'trapdoor', {'name': 'trapdoor',
'exits_to': 'dungeon_level_id'}] 'exits_to': 'dungeon_level_id'}]
""" """
pass target = database['levels'].find(
{'exits': {'$type': 3}})
for level in target:
new_exits = []
for exit_name, exits_to in level['exits'].items():
new_exits.append(
{'name': exit_name,
'exits_to': exits_to})
level['exits'] = new_exits
database['levels'].save(level)
UNMIGRATED_DBDATA = { UNMIGRATED_DBDATA = {