fix(alembic 0025): qualify ambiguous post.id / post.source_id in fragment-group SELECT (post JOIN source — both have id)

This commit is contained in:
2026-05-27 15:45:42 -04:00
parent b7b313cc05
commit aa28bddeab
@@ -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()