Fix possibility of extra mention insertion on nonce collision

This commit is contained in:
Max Brunsfeld 2023-10-18 18:04:54 -07:00
parent b07f9fe3b5
commit ac54d2b927
6 changed files with 204 additions and 171 deletions

View file

@ -5,3 +5,7 @@ CREATE TABLE "channel_message_mentions" (
"user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
PRIMARY KEY(message_id, start_offset)
);
-- We use 'on conflict update' with this index, so it should be per-user.
CREATE UNIQUE INDEX "index_channel_messages_on_sender_id_nonce" ON "channel_messages" ("sender_id", "nonce");
DROP INDEX "index_channel_messages_on_nonce";