-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pins)_: delete pins when the og message is deleted (#6173)
Found when fixing status-im/status-desktop#16639 When a message is deleted, we need to delete the pins too as they are no longer available. This was done using an ON DELETE clause (thanks @osmaczko) I also made sure the SELECT query for the pins doesn't return deleted messages
- Loading branch information
1 parent
137698e
commit 5a8310d
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
19 changes: 19 additions & 0 deletions
19
protocol/migrations/sqlite/1733428521_pinned_messages_add_on_delete_clause.up.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE TABLE pin_messages_new ( | ||
id VARCHAR PRIMARY KEY NOT NULL, | ||
message_id VARCHAR NOT NULL, | ||
whisper_timestamp INTEGER NOT NULL, | ||
chat_id VARCHAR NOT NULL, | ||
local_chat_id VARCHAR NOT NULL, | ||
clock_value INT NOT NULL, | ||
pinned BOOLEAN NOT NULL, | ||
pinned_by TEXT, | ||
FOREIGN KEY (message_id) REFERENCES user_messages(id) ON DELETE CASCADE | ||
); | ||
|
||
INSERT INTO pin_messages_new (id, message_id, whisper_timestamp, chat_id, local_chat_id, clock_value, pinned, pinned_by) | ||
SELECT id, message_id, whisper_timestamp, chat_id, local_chat_id, clock_value, pinned, pinned_by | ||
FROM pin_messages; | ||
|
||
DROP TABLE pin_messages; | ||
|
||
ALTER TABLE pin_messages_new RENAME TO pin_messages; |
This file contains 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