Repository navigation
fix(api): delete message reactions before purging a channel account - #524
Merged
Merged
Conversation
message_reactions.channel_account_id references channel_accounts with ON DELETE RESTRICT, but purgeArchivedChannelAccount never deleted the reactions, so purging any archived Telegram account that had a single reaction failed and rolled back every time. Delete the account's reactions, and reactions on its messages that have no channel_account_id (message_id has no foreign key), before the messages and the account. Fixes #380
setkyar
force-pushed
the
fix/purge-channel-account-reactions
branch
from
November 23, 2026 17:46
fe7a9c4 to
36acc5b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #380.
Problem
message_reactions.channel_account_idreferenceschannel_accountswithON DELETE RESTRICT, butpurgeArchivedChannelAccountnever deleted the reactions. Purging any archived Telegram (channel-neutral) account with even one reaction failed and rolled back every time.Fix
Before deleting the messages and the account, delete:
channel_account_id(message_idhas no foreign key, so these would otherwise be left orphaned).Everything stays inside the existing purge transaction.
Tests
channel_account_idand a legacy one without it. Both are deleted and the purge completes. A reaction belonging to another account survives.main. Typecheck, biome andchannel-account-purge.integration.test.tspass on a fresh Postgres 18.Release
No migration.
worker: skip.