Skip to content

Instantly share code, notes, and snippets.

@wont-work
Created January 31, 2024 17:20
Show Gist options
  • Save wont-work/e95684b80ba89849db1e4a46edbc59f7 to your computer and use it in GitHub Desktop.
Save wont-work/e95684b80ba89849db1e4a46edbc59f7 to your computer and use it in GitHub Desktop.
the cursed sql to convert all heart reactions to star reactions in misskey
BEGIN;
UPDATE note_reaction
SET reaction='⭐'
WHERE reaction='❤';
UPDATE note
SET reactions = jsonb_set(reactions, '{⭐}', ((reactions->>'❤')::int + coalesce((reactions->>'⭐')::int, 0))::text::jsonb)
WHERE (reactions->>'❤')::int >= 0;
UPDATE note
SET reactions = reactions - '❤'
WHERE (reactions->>'❤')::int >= 0;
update note
set "reactionAndUserPairCache" = array(select replace(unnest("reactionAndUserPairCache"), '❤', '⭐'))
where "reactionAndUserPairCache" != '{}';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment