feat: post reshare enhancements
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
-- This is a data-only backfill — there's no clean rollback because we
|
||||
-- can't distinguish post_images rows added by this migration from rows
|
||||
-- the resharer added afterwards. Intentional no-op; documented for the
|
||||
-- runbook only.
|
||||
SELECT 1;
|
||||
@@ -0,0 +1,29 @@
|
||||
-- Backfill the "reshares inherit the canonical's images" rule for any
|
||||
-- reshare row that landed in `posts` without an image set.
|
||||
--
|
||||
-- Two paths created such rows:
|
||||
--
|
||||
-- 1. Reshares made BEFORE migration 0014 had no per-resharer image
|
||||
-- table to snapshot into, so when 0015 collapsed the old
|
||||
-- post_reshares model into real posts rows there was nothing for
|
||||
-- it to copy — those reshares now show with a blank background
|
||||
-- where the original author has a cover image.
|
||||
--
|
||||
-- 2. Any future code path that creates a reshare row but forgets to
|
||||
-- copy the images. Defensive — current `Reshare` in
|
||||
-- internal/repository/post_repo.go does copy, but this migration
|
||||
-- makes the database self-healing if we ever regress.
|
||||
--
|
||||
-- The copy is scoped to reshares with ZERO images of their own so we
|
||||
-- never overwrite a resharer's explicit customization (including an
|
||||
-- explicit "no background" — though that path didn't exist at the time
|
||||
-- the affected rows were created, the guard keeps us safe for any
|
||||
-- future re-runs of equivalent backfills).
|
||||
INSERT INTO post_images (post_id, url, position)
|
||||
SELECT r.id, i.url, i.position
|
||||
FROM posts r
|
||||
JOIN post_images i ON i.post_id = r.reshared_from_post_id
|
||||
WHERE r.reshared_from_post_id IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM post_images WHERE post_id = r.id
|
||||
);
|
||||
Reference in New Issue
Block a user