aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/migrations.py
diff options
context:
space:
mode:
authorJessica Tallon <tsyesika@tsyesika.se>2015-12-28 13:27:41 +0000
committerJessica Tallon <tsyesika@tsyesika.se>2015-12-29 16:42:37 +0000
commitbf79b8bd5b8923026ad6f80ac98fa3e503fdc125 (patch)
treefa48a2752ca895c25ad04bd688e8e0ce6255e9aa /mediagoblin/db/migrations.py
parentccd9dabe751f3a43573e4c5ba637e9dceb84d09b (diff)
downloadmediagoblin-bf79b8bd5b8923026ad6f80ac98fa3e503fdc125.tar.lz
mediagoblin-bf79b8bd5b8923026ad6f80ac98fa3e503fdc125.tar.xz
mediagoblin-bf79b8bd5b8923026ad6f80ac98fa3e503fdc125.zip
Fix migrations of activity intermediators
There was a problem where it was assuming the tablenames are the same in master as they always were and that isn't the case. This would cause it to raise an exception when trying to look up a table which didn't exist. This fixes that by hardcoding the old tablenames in for this migration.
Diffstat (limited to 'mediagoblin/db/migrations.py')
-rw-r--r--mediagoblin/db/migrations.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 1c159511..73807649 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -914,11 +914,11 @@ class ActivityIntermediator_R0(declarative_base()):
type = Column(Unicode, nullable=False)
# These are needed for migration 29
- TYPES = {
- "user": User,
- "media": MediaEntry,
- "comment": Comment,
- "collection": Collection,
+ TABLENAMES = {
+ "user": "core__users",
+ "media": "core__media_entries",
+ "comment": "core__media_comments",
+ "collection": "core__collections",
}
class Activity_R0(declarative_base()):
@@ -1324,8 +1324,8 @@ def migrate_data_foreign_keys(db):
ai_table.c.id==activity.object
)).first()
- object_ai_type = ActivityIntermediator_R0.TYPES[object_ai.type]
- object_ai_table = inspect_table(metadata, object_ai_type.__tablename__)
+ object_ai_type = ActivityIntermediator_R0.TABLENAMES[object_ai.type]
+ object_ai_table = inspect_table(metadata, object_ai_type)
activity_object = db.execute(object_ai_table.select(
object_ai_table.c.activity==object_ai.id
@@ -1334,7 +1334,7 @@ def migrate_data_foreign_keys(db):
# now we need to create the GenericModelReference
object_gmr = db.execute(gmr_table.insert().values(
obj_pk=activity_object.id,
- model_type=object_ai_type.__tablename__
+ model_type=object_ai_type
))
# Now set the ID of the GenericModelReference in the GenericForignKey
@@ -1353,8 +1353,8 @@ def migrate_data_foreign_keys(db):
ai_table.c.id==activity.target
)).first()
- target_ai_type = ActivityIntermediator_R0.TYPES[target_ai.type]
- target_ai_table = inspect_table(metadata, target_ai_type.__tablename__)
+ target_ai_type = ActivityIntermediator_R0.TABLENAMES[target_ai.type]
+ target_ai_table = inspect_table(metadata, target_ai_type)
activity_target = db.execute(target_ai_table.select(
target_ai_table.c.activity==target_ai.id
@@ -1363,7 +1363,7 @@ def migrate_data_foreign_keys(db):
# We now want to create the new target GenericModelReference
target_gmr = db.execute(gmr_table.insert().values(
obj_pk=activity_target.id,
- model_type=target_ai_type.__tablename__
+ model_type=target_ai_type
))
# Now set the ID of the GenericModelReference in the GenericForignKey