Skip to content

refactor: change messages primary key to (channel_id, arrived_at) - #551

Merged
boxdot merged 5 commits into
mainfrom
dima/composite-pk
Jul 11, 2026
Merged

refactor: change messages primary key to (channel_id, arrived_at)#551
boxdot merged 5 commits into
mainfrom
dima/composite-pk

Conversation

@boxdot

@boxdot boxdot commented Jun 12, 2026

Copy link
Copy Markdown
Owner

The primary key on arrived_at alone was globally unique, so REPLACE in
store_message could silently delete a message with the same timestamp
in another channel. The composite key matches the semantics of
MessageId and serves as the index for windowed message queries.

Also link messages to their channel via a foreign key (deleting a
channel deletes its messages), and remove Storage::message_channel,
which is ambiguous under the composite key.

boxdot added 5 commits June 12, 2026 17:51
The primary key on arrived_at alone was globally unique, so REPLACE in
store_message could silently delete a message with the same timestamp
in another channel. The composite key matches the semantics of
MessageId and serves as the index for windowed message queries.

Also link messages to their channel via a foreign key (deleting a
channel deletes its messages), and remove Storage::message_channel,
which is ambiguous under the composite key.
@boxdot
boxdot enabled auto-merge (squash) July 11, 2026 18:31
@boxdot
boxdot merged commit 671a4b1 into main Jul 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant