mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 22:26:30 +00:00
b01a861e8e
This adds a new `DiscordMessageAttachment` type which is part of `DiscordMessage`. Along with that type, there's also a new database table for `discord_message_attachments` and corresponding persistence APIs. This commit also changes how chat messages are retrieved. Here's why: `DiscordMessage` can have multiple `DiscordMessageAttachment`. A chat message can have a `DiscordMessage`. Because we're `LEFT JOIN`'ing the discord message attachments into the chat messages, there's a possibility of multiple rows per message. Hence, this commit ensures we collect queried discord message attachments on chat messages.
How to write migrations?
We only write up
migrations, down
migrations are not always possible in sqlite or
too complex/too expensive. For example to remove a column you would have to duplicate
the table, copy over the data, delete and recreated.
This can be very expensive for some tables (user_messages for example), so should not be attempted.
Notes
One issue we faced multiple times is that updates to user_messages
can be very
expensive, leading to slow upgrade times and interrupted migrations. So avoid
writes if not necessary.