diff options
author | Jessica Tallon <tsyesika@tsyesika.se> | 2015-06-24 21:22:03 +0200 |
---|---|---|
committer | Jessica Tallon <tsyesika@tsyesika.se> | 2015-06-24 21:43:16 +0200 |
commit | ddc2db746f3291dbe11393a814eed9a0fd651365 (patch) | |
tree | 69c068c19c82875a16fbcd8dbe00c50b74c17873 /mediagoblin/db/migrations.py | |
parent | 2d73983e8ca353f47ad25642e1e0c292d94b20d5 (diff) | |
download | mediagoblin-ddc2db746f3291dbe11393a814eed9a0fd651365.tar.lz mediagoblin-ddc2db746f3291dbe11393a814eed9a0fd651365.tar.xz mediagoblin-ddc2db746f3291dbe11393a814eed9a0fd651365.zip |
Fix removal of ActivityIntermediatory migration
The migration had a problem where other tables still referenced the migration
as well as a typo in an earlier migration. They have both been fixed and tested
on PostgreSQL and SQLite3.
This also fixes a bug where sometimes when creating an activity it'd raise an
Exception as the object hadn't got an ID. This has been fixed globally with a
fix to the create_activity federation tool.
Diffstat (limited to 'mediagoblin/db/migrations.py')
-rw-r--r-- | mediagoblin/db/migrations.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index 9ecd6e62..4f2f8915 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -1289,10 +1289,10 @@ def add_foreign_key_fields(db): activity_table = inspect_table(metadata, "core__activities") # Create column and add to model. - object_column = Column("temp_object", Integer, ForeignKey(GenericModelReference_V0)) + object_column = Column("temp_object", Integer, ForeignKey(GenericModelReference_V0.id)) object_column.create(activity_table) - target_column = Column("temp_target", Integer, ForeignKey(GenericModelReference_V0)) + target_column = Column("temp_target", Integer, ForeignKey(GenericModelReference_V0.id)) target_column.create(activity_table) # Commit this to the database @@ -1406,6 +1406,23 @@ def remove_activityintermediator(db): """ metadata = MetaData(bind=db.bind) + # Remove the columns which reference the AI + collection_table = inspect_table(metadata, "core__collections") + collection_ai_column = collection_table.columns["activity"] + collection_ai_column.drop() + + media_entry_table = inspect_table(metadata, "core__media_entries") + media_entry_ai_column = media_entry_table.columns["activity"] + media_entry_ai_column.drop() + + comments_table = inspect_table(metadata, "core__media_comments") + comments_ai_column = comments_table.columns["activity"] + comments_ai_column.drop() + + user_table = inspect_table(metadata, "core__users") + user_ai_column = user_table.columns["activity"] + user_ai_column.drop() + # Drop the table ai_table = inspect_table(metadata, "core__activity_intermediators") ai_table.drop() |