diff --git a/alembic/versions/0025_fix_subscribestar_post_ids.py b/alembic/versions/0025_fix_subscribestar_post_ids.py index 2baa72b..b44f430 100644 --- a/alembic/versions/0025_fix_subscribestar_post_ids.py +++ b/alembic/versions/0025_fix_subscribestar_post_ids.py @@ -188,12 +188,13 @@ def upgrade() -> None: # Merge to one canonical row. Pre-handle the same ImageProvenance # collision pattern as alembic 0022 (uq_image_provenance_image_post). fragment_groups = conn.execute(text(""" - SELECT source_id, external_post_id, ARRAY_AGG(id ORDER BY id ASC) AS post_ids + SELECT p.source_id, p.external_post_id, + ARRAY_AGG(p.id ORDER BY p.id ASC) AS post_ids FROM post p JOIN source s ON s.id = p.source_id WHERE s.platform = 'subscribestar' AND p.external_post_id IS NOT NULL - GROUP BY source_id, external_post_id + GROUP BY p.source_id, p.external_post_id HAVING COUNT(*) > 1 """)).fetchall()