feat(migrations): canonicalize socials twitter.com → x.com + merge twin rows#40
Conversation
…win rows Companion to recoupable/api#755 (normalizeProfileUrl canonicalization). Merges 403 twitter/x twin pairs (repointing 7 FK columns with unique- constraint guards) and renames 23,622 twinless twitter.com keys in place. Post-condition check raises if any twitter.com key survives. Tracking: recoupable/chat#1851 (PR #2 of 2 required). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Updates to Preview Branch (fix/x-domain-dedupe-socials) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="supabase/migrations/20260706180000_canonicalize_twitter_to_x_socials.sql">
<violation number="1" location="supabase/migrations/20260706180000_canonicalize_twitter_to_x_socials.sql:135">
P2: Twinless twitter→x renames will still bump `socials.updated_at`, so rows can look freshly scraped even though only `profile_url` changed. `updated_at = updated_at` does not bypass the table’s `set_updated_at` trigger; preserving timestamps needs trigger bypass/restore or an explicit post-update restoration step.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| -- 2. Twinless twitter rows: rename the key in place. | ||
| UPDATE public.socials | ||
| SET profile_url = 'x.com/' || substring(profile_url FROM 13), | ||
| updated_at = updated_at -- key rename only; not a data refresh |
There was a problem hiding this comment.
P2: Twinless twitter→x renames will still bump socials.updated_at, so rows can look freshly scraped even though only profile_url changed. updated_at = updated_at does not bypass the table’s set_updated_at trigger; preserving timestamps needs trigger bypass/restore or an explicit post-update restoration step.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At supabase/migrations/20260706180000_canonicalize_twitter_to_x_socials.sql, line 135:
<comment>Twinless twitter→x renames will still bump `socials.updated_at`, so rows can look freshly scraped even though only `profile_url` changed. `updated_at = updated_at` does not bypass the table’s `set_updated_at` trigger; preserving timestamps needs trigger bypass/restore or an explicit post-update restoration step.</comment>
<file context>
@@ -0,0 +1,147 @@
+-- 2. Twinless twitter rows: rename the key in place.
+UPDATE public.socials
+SET profile_url = 'x.com/' || substring(profile_url FROM 13),
+ updated_at = updated_at -- key rename only; not a data refresh
+WHERE profile_url LIKE 'twitter.com/%';
+
</file context>
Summary
Data-migration companion to api#755: rewrites all
socials.profile_urltwitter.com/*keys to the canonicalx.com/*domain and merges rows where both spellings exist, so X scrape write-backs land on the rows artists are actually connected to.Tracking issue: recoupable/chat#1851 (PR #2 of 2 required). Canonical-domain decision (x.com) recorded there 2026-07-06.
What it does
x.comrow is the keeper. Backfills any fresher scrape fields from the loser, repoints all 7 FK columns referencingsocials.id(account_socials.social_id,social_posts.social_id,post_comments.social_id,social_fans.artist_social_id,social_fans.fan_social_id,fan_segments.fan_social_id,agent_status.social_id) with delete-guards on each table's unique/logical key, then deletes the loser.twitter.com/<handle>→x.com/<handle>.twitter.com/*key survives, so a partial run cannot commit silently.Verification (dry-run against prod inside a rolled-back transaction, 2026-07-06)
twitter.com/*rows remainingx.com/*rows afterx.com/*keepersx.com/disclosurekeeper carries the fresh scrapeMerge sequencing
api#755 merges first (stops new
twitter.comkeys being written), then this migration cleans up existing rows. Running this first would also work but re-drift until the api change deploys.🤖 Generated with Claude Code
Summary by cubic
Canonicalizes socials from twitter.com to x.com by merging duplicate rows and repointing foreign keys so X scraper write-backs attach to artist-connected records. Twinless twitter rows are renamed in place, and the migration fails if any twitter.com keys remain.
Written for commit 981c173. Summary will update on new commits.