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.
This commit is contained in:
parent
2d73983e8c
commit
ddc2db746f
@ -1289,10 +1289,10 @@ def add_foreign_key_fields(db):
|
|||||||
activity_table = inspect_table(metadata, "core__activities")
|
activity_table = inspect_table(metadata, "core__activities")
|
||||||
|
|
||||||
# Create column and add to model.
|
# 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)
|
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)
|
target_column.create(activity_table)
|
||||||
|
|
||||||
# Commit this to the database
|
# Commit this to the database
|
||||||
@ -1406,6 +1406,23 @@ def remove_activityintermediator(db):
|
|||||||
"""
|
"""
|
||||||
metadata = MetaData(bind=db.bind)
|
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
|
# Drop the table
|
||||||
ai_table = inspect_table(metadata, "core__activity_intermediators")
|
ai_table = inspect_table(metadata, "core__activity_intermediators")
|
||||||
ai_table.drop()
|
ai_table.drop()
|
||||||
|
@ -71,6 +71,10 @@ def create_activity(verb, obj, actor, target=None, generator=None):
|
|||||||
)
|
)
|
||||||
generator.save()
|
generator.save()
|
||||||
|
|
||||||
|
# Ensure the object has an ID which is needed by the activity.
|
||||||
|
obj.save(commit=False)
|
||||||
|
|
||||||
|
# Create the activity
|
||||||
activity = Activity(verb=verb)
|
activity = Activity(verb=verb)
|
||||||
activity.object = obj
|
activity.object = obj
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user