Skip to content

fix(offline-support): foreign constraint failure#2472

Merged
khushal87 merged 7 commits intodevelopfrom
fix-foreign-constriant
Apr 2, 2024
Merged

fix(offline-support): foreign constraint failure#2472
khushal87 merged 7 commits intodevelopfrom
fix-foreign-constriant

Conversation

@santhoshvai
Copy link
Copy Markdown
Member

@santhoshvai santhoshvai commented Apr 2, 2024

🎯 Goal

To fix foreign key constriant failure

upsertMessages touches three tables: 1. messages 2. users 3. reactions.. so either of these foreign key fails

  • table: messages - foreign_key: [cid]
  • table: users - foreign_key: []
  • table: reactions - foreign_key: ['messageId', 'userId']

cases of failure

  1. a message update from BE without the channel being in our local DB -- from channel hide
  2. a message update from BE but the reaction's user or message is not in the local DB -- due to wrong order where reactions are upserted before users

🛠 Implementation details

case 1: add the channel again to DB before inserting the message
case 2: correct the order -- this was unknowingly already fixed in 5.26!

🧪 Testing

  • Send a message to a channel that is hidden for a member from other member in the channel

☑️ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the develop branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

@khushal87 khushal87 merged commit 0119754 into develop Apr 2, 2024
@khushal87 khushal87 deleted the fix-foreign-constriant branch April 2, 2024 17:48
@github-actions github-actions Bot mentioned this pull request Apr 2, 2024
@stream-ci-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.27.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants